Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle type NCHAR is not supported by OracleDialect.get_columns #4506

Closed
altvod opened this issue Feb 19, 2019 · 4 comments
Closed

Oracle type NCHAR is not supported by OracleDialect.get_columns #4506

altvod opened this issue Feb 19, 2019 · 4 comments
Labels
bug Something isn't working datatypes things to do with database types, like VARCHAR and others easy a one / two liner type of thing that anyone can do in short order. also see "fairly easy" oracle reflection reflection of tables, columns, constraints, defaults, sequences, views, everything else
Milestone

Comments

@altvod
Copy link

altvod commented Feb 19, 2019

If you try to inspect an Oracle table with NCHAR columns, they are returned as NullType()
The following code demonstrates it:

import sqlalchemy as sa
e = make_engine()  # create your Oracle engine somehow
table = sa.Table(
    'my_table', sa.MetaData(),
    sa.Column(name='my_char', type_=sa.CHAR()),
    sa.Column(name='my_nchar', type_=sa.NCHAR()),
)
table.drop(e, checkfirst=True)
table.create(e)
for col in sa.inspect(e).get_columns('my_table'):
    print(col['name'], repr(col['type']))

It will print:

my_char CHAR(length=1)
my_nchar NullType()
@zzzeek zzzeek added bug Something isn't working easy a one / two liner type of thing that anyone can do in short order. also see "fairly easy" oracle reflection reflection of tables, columns, constraints, defaults, sequences, views, everything else datatypes things to do with database types, like VARCHAR and others labels Feb 19, 2019
@zzzeek zzzeek added this to the 1.2.x milestone Feb 19, 2019
@zzzeek
Copy link
Member

zzzeek commented Feb 19, 2019

OK this just needs to be added to ischema_names and some other places, and by the time I work out all the spots for someones PR, the patch is here so I'll just push that up

@zzzeek
Copy link
Member

zzzeek commented Feb 19, 2019

you can do this for now:

from sqlalchemy.types import NCHAR
from sqlalchemy.dialects.oracle import base
base.ischema_names['NCHAR'] = NCHAR

the reflected datatype will just be missing the length at the moment.

@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the master branch:

Add NCHAR to Oracle dialect https://gerrit.sqlalchemy.org/1138

@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the rel_1_2 branch:

Add NCHAR to Oracle dialect https://gerrit.sqlalchemy.org/1139

sqlalchemy-bot pushed a commit that referenced this issue Feb 20, 2019
Added support for reflection of the :class:`.NCHAR` datatype to the Oracle
dialect, and added :class:`.NCHAR` to the list of types exported by the
Oracle dialect.

Fixes: #4506
Change-Id: I3a120b9ad714cbd0ebd8064519f43cf57e99d920
(cherry picked from commit 5fe9da5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datatypes things to do with database types, like VARCHAR and others easy a one / two liner type of thing that anyone can do in short order. also see "fairly easy" oracle reflection reflection of tables, columns, constraints, defaults, sequences, views, everything else
Projects
None yet
Development

No branches or pull requests

3 participants