Skip to content

outputtypehandler not respecting NLS_TERRITORY in thin mode #11

@CaselIT

Description

@CaselIT
  1. What versions are you using?
platform.platform: Windows-10-10.0.19044-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.10.4
oracledb.__version__: 1.0.0

I'm using oracle 21.3.0.0, with client version (21, 3, 0, 0, 0)

  1. Is it an error or a hang or a crash?

An unexpected result was returned

  1. What error(s) or behavior you are seeing?

It seems that setting NLS_TERRITORY on the session and using outputtypehandler to return floating values to string does not take into consideration the set NLS_TERRITORY parameter

  1. Does your application call init_oracle_client()?

both

  1. Include a runnable Python script that shows the problem.
import oracledb

thin_mode = True
if not thin_mode:
    oracledb.init_oracle_client()

def go():
    with oracledb.connect(
        user="scott",
        password="tiger",
        service_name="XEPDB1",
        host="localhost",
        port=11521,
    ) as conn:
        cursor = conn.cursor()
        # NLS_TERRITORY can be set to any nation that uses comma. also GERMANY works
        cursor.execute("ALTER SESSION SET NLS_TERRITORY='ITALY'")
        res = cursor.execute(
            "select cast(1.1 as varchar(128)) from dual"
        ).fetchall()[0]
        print("with cast", res[0], res[0] == "1,1")

        def output_type_handler(
            cursor, name, defaultType, size, precision, scale
        ):
            return cursor.var(oracledb.STRING, 255, arraysize=cursor.arraysize)

        cursor.outputtypehandler = output_type_handler
        res = cursor.execute("select 1.1 from dual").fetchall()[0]
        print("with outputtypehandler", res[0], res[0] == "1,1")

go()

with thin_mode = True the above script prints the following.

with cast 1,1 True
with outputtypehandler 1.1 False

the second print ignores the NLS_TERRITORY setting.
Setting thin_mode = False prints the expected

with cast 1,1 True
with outputtypehandler 1,1 True

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions