From a5f2aab9e0177b32aebb23ea4393c1f71a5e8831 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 5 Dec 2007 21:14:09 +0000 Subject: [PATCH] - tables with schemas can still be used in sqlite, firebird, schema name just gets dropped [ticket:890] --- CHANGES | 3 +++ lib/sqlalchemy/sql/compiler.py | 2 +- test/engine/reflection.py | 10 +++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 3b212fe82f..f323bdab8d 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,9 @@ CHANGES advised that all unicode-aware applications make proper use of Python unicode objects (i.e. u'hello' and not 'hello'). + - tables with schemas can still be used in sqlite, firebird, + schema name just gets dropped [ticket:890] + - changed the various "literal" generation functions to use an anonymous bind parameter. not much changes here except their labels now look like ":param_1", ":param_2" instead of ":literal" diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index ea7c1b7345..1cbfd94d24 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1021,7 +1021,7 @@ class IdentifierPreparer(object): if name is None: name = table.name result = self.quote(table, name) - if use_schema and getattr(table, "schema", None): + if not self.omit_schema and use_schema and getattr(table, "schema", None): result = self.quote(table, table.schema) + "." + result return result diff --git a/test/engine/reflection.py b/test/engine/reflection.py index 756f42224e..0d2fa28188 100644 --- a/test/engine/reflection.py +++ b/test/engine/reflection.py @@ -726,8 +726,8 @@ class UnicodeTest(PersistTest): class SchemaTest(PersistTest): + # this test should really be in the sql tests somewhere, not engine - @testing.unsupported('sqlite', 'firebird') def test_iteration(self): metadata = MetaData() table1 = Table('table1', metadata, @@ -748,8 +748,12 @@ class SchemaTest(PersistTest): gen.traverse(table2) buf = buf.getvalue() print buf - assert buf.index("CREATE TABLE someschema.table1") > -1 - assert buf.index("CREATE TABLE someschema.table2") > -1 + if testbase.db.dialect.preparer(testbase.db.dialect).omit_schema: + assert buf.index("CREATE TABLE table1") > -1 + assert buf.index("CREATE TABLE table2") > -1 + else: + assert buf.index("CREATE TABLE someschema.table1") > -1 + assert buf.index("CREATE TABLE someschema.table2") > -1 @testing.supported('maxdb', 'mysql', 'postgres') def test_explicit_default_schema(self): -- 2.47.3