diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-29 18:09:25 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-29 18:09:25 -0400 |
| commit | 4da020dae324cb871074e302f4840e8731988be0 (patch) | |
| tree | 68f6a140b42d331ab7591d01c5931a5b129778b1 /lib/sqlalchemy/dialects/sqlite/base.py | |
| parent | b6496ba3d28d685547eac2891bfea5f4ae60e834 (diff) | |
| download | sqlalchemy-4da020dae324cb871074e302f4840e8731988be0.tar.gz | |
- rework tests for attached databases into individual tests,
test both memory and file-based
- When selecting from a UNION using an attached database file,
the pysqlite driver reports column names in cursor.description
as 'dbname.tablename.colname', instead of 'tablename.colname' as
it normally does for a UNION (note that it's supposed to just be
'colname' for both, but we work around it). The column translation
logic here has been adjusted to retrieve the rightmost token, rather
than the second token, so it works in both cases. Workaround
courtesy Tony Roberts.
fixes #3211
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite/base.py')
| -rw-r--r-- | lib/sqlalchemy/dialects/sqlite/base.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 817834b7d..335b35c94 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -713,10 +713,12 @@ class SQLiteExecutionContext(default.DefaultExecutionContext): return self.execution_options.get("sqlite_raw_colnames", False) def _translate_colname(self, colname): - # adjust for dotted column names. SQLite in the case of UNION may - # store col names as "tablename.colname" in cursor.description + # adjust for dotted column names. SQLite + # in the case of UNION may store col names as + # "tablename.colname", or if using an attached database, + # "database.tablename.colname", in cursor.description if not self._preserve_raw_colnames and "." in colname: - return colname.split(".")[1], colname + return colname.split(".")[-1], colname else: return colname, None |
