Re: [Sqlalchemy-tickets] [sqlalchemy] #1428: ORM queries not doing appropriate type-conversion for
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2009-06-04 18:14:11
|
#1428: ORM queries not doing appropriate type-conversion for queries on mapped classes where the table has a multi-part schema --------------------------------+------------------------------------------- Reporter: phrrngtn | Owner: phrrngtn Type: defect | Status: new Priority: medium | Milestone: Component: engine | Severity: no triage selected yet Resolution: | Keywords: mssql, multi-part schema name Status_field: awaiting triage | --------------------------------+------------------------------------------- Comment (by phrrngtn): What a flip-flopper I am today! after writing the unit tests, I see that there are a bunch of additional checks that we would have to make to ensure that the generated label is valid as a Python identifier. It seems much more reasonable to me to try and fix the bug with SQLite prepending the table-name to the column name in the cursor description that to go to any great lengths to avoid '.' appearing in any component of the object name ... if the identifier has been correctly quoted/escaped in the SQL then why should we care what form the names are in the result-set? So I propose the patch below but realize that it may break if the column names contain a period e.g. sqlite> create table foo ([I am not dotty even I do have a '.' in my name] integer) ...> ; sqlite> .schema foo CREATE TABLE foo ([I am not dotty even I do have a '.' in my name] integer); pjjH Index: lib/sqlalchemy/engine/base.py =================================================================== --- lib/sqlalchemy/engine/base.py (revision 6022) +++ lib/sqlalchemy/engine/base.py (working copy) @@ -1450,7 +1450,7 @@ if self.dialect.description_encoding: colname = colname.decode(self.dialect.description_encoding) - if '.' in colname: + if '.' in colname and self.dialect.name == 'sqlite': # sqlite will in some circumstances prepend table name to colnames, so strip origname = colname colname = colname.split('.')[-1] -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1428#comment:5> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |