Skip to content

more confusion about binding NATIVE_INT #257

@zzzeek

Description

@zzzeek

"question" label here, because as usual I can see why this is happening, it is just another surprise (note I differentiate between "surprise" and "expected" :) )

In SQLAlchemy, we have an outputtypehandler that in one particular case, is essentially this:

def handler(cursor, name, default_type, size, precision, scale):

    if precision and scale == 0:
        return cursor.var(
            cx_Oracle.NATIVE_INT,
            255,
            arraysize=cursor.arraysize,
            outconverter=None,
        )

    else:
        return None

it seems well intentioned enough until one of my users decided to stick 9999999999999999999 into it, producing the error:

cx_Oracle.DatabaseError: ORA-01455: converting column overflows integer datatype

Apparently the max int size for NATIVE_INT is 32 bits, so...maybe if you can confirm that, and what kind of datatype is coming back if I dont do that. What's the purpose of NATIVE_INT exactly, and do I have to worry about this on the input side as well (though this user hasn't tried that yet :) )

I can either not return a var at all, or I can do this:

    return cursor.var(
        int, 255, arraysize=cursor.arraysize, outconverter=None
    )

and both of those seem to work great for everything I'm testing plus these new tests. In #208 it seemed like I had decided to use NATIVE_INT but that was on the input side. On the output side can you confirm I should set "int" on the var and/or not return the var?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions