On Apr 9, 2011, at 6:15 PM, Anoop wrote:

> 
> HI Michael ,
>   Thanks for your reply,this is my table creation query without any
> quoted variables
> 
> CREATE TABLE AUTOLOAD_TEST
> (
>  ID INTEGER
> , FIRST_NAME VARCHAR(20)
> );
> 
> this is my connect_sqlalchemy.py script
> ++++++++++++++++++++++++++++++++++++++++++
> 
> from sqlalchemy import MetaData,create_engine,Table
> engine = create_engine("oracle+cx_oracle://anoop:asdfgh@xe" )
> meta = MetaData(engine)
> tbl_autoload_test=Table('autoload_test', meta, autoload=True,
>                    autoload_with=engine, schema=None)
> print tbl_autoload_test.columns.keys()
> ++++++++++++++++++++++++++++++++++++++++++
> 
> When I run this script
> (myenv)anoop@AGLAP:~/Example/sqlalchemy$ python connect_sqlalchemy.py
> [u'id', u'first_name']  #Here I got column names in lower case
> 
> 
>        if name.upper() == name and \
>              not
> self.identifier_preparer._requires_quotes(name.lower()):
>            return name.lower()
>        else:
>            return name

>        if name.upper() == name and \
>              not self.identifier_preparer._requires_quotes(name): #
> this is my change not converted into lower when calling
>            return name.lower()
>        else:
>            return name
> 
> [u'ID', u'FIRST_NAME'] # Here output is in Capital letters not
> 
> Did you got my point  ?

I'm assuming what you're looking for here is columns.keys() to be converted to 
uppercase.   To be honest, to suit your use case, you should just say my_keys = 
[k.upper() for k in table.columns.keys() if k.lower() == k].   Because you 
shouldn't be thinking of those names as upper case *or*  lowercase - they are 
case insensitive.   SQLA uses all lower case to indicate case insensitive, 
Oracle uses all uppercase.  You can emit the statement "select FIRST_NAME from 
autoload_test" or "select first_name from autoload_test" on your oracle 
database and you get the same result.

With your change, we basically treat Oracle names as UPPERCASE for case 
insensitive, the way Oracle itself does.  Which is the reverse of the usage 
contract that SQLAlchemy provides for all other backends.   Tables now have to 
be referenced as table.c.SOME_COLUMN, mapped classes will look like 
MyClass.FIRST_NAME, etc.      If I make your change, symmetrically or not 
versus denormalize_name, there are dozens of test failures, illustrated here: 
http://paste.pocoo.org/show/368744/ .  All the tests in test_reflection are 
normally fully cross-platform compatible.  If we make an arbitrary reversal of 
SQLAlchemy's case insensitive convention in the case of Oracle, virtually all 
tests regarding reflection do not act as expected.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to