summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-11-16 09:57:36 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-11-16 10:00:36 -0500
commit68d3018ceefc33e42135ee208d6d492a47e695c7 (patch)
tree773fd00123c02d9913fd36087e0e9ba2e34f3f32 /lib/sqlalchemy/testing
parent772042ea851062b75df3baf22b08740bd7820656 (diff)
downloadsqlalchemy-68d3018ceefc33e42135ee208d6d492a47e695c7.tar.gz
Port lower case quoted name fix to firebird
Ported the fix for Oracle quoted-lowercase names to Firebird, so that a table name that is quoted as lower case can be reflected properly including when the table name comes from the get_table_names() inspection function. Also genericize the test to the test suite for denormlized name dialects. Fixes: #3548 Change-Id: I8ca62e8d2b359e363ccb01cfe2daa0995354a3cb
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/suite/test_reflection.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py
index 090d5b067..ed6a33b6d 100644
--- a/lib/sqlalchemy/testing/suite/test_reflection.py
+++ b/lib/sqlalchemy/testing/suite/test_reflection.py
@@ -14,6 +14,8 @@ from .. import config
import operator
from sqlalchemy.schema import DDL, Index
from sqlalchemy import event
+from sqlalchemy.sql.elements import quoted_name
+from sqlalchemy import ForeignKey
metadata, users = None, None
@@ -705,4 +707,40 @@ class ComponentReflectionTest(fixtures.TablesTest):
assert id_.get('autoincrement', True)
-__all__ = ('ComponentReflectionTest', 'HasTableTest')
+class NormalizedNameTest(fixtures.TablesTest):
+ __requires__ = 'denormalized_names',
+ __backend__ = True
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table(
+ quoted_name('t1', quote=True), metadata,
+ Column('id', Integer, primary_key=True),
+ )
+ Table(
+ quoted_name('t2', quote=True), metadata,
+ Column('id', Integer, primary_key=True),
+ Column('t1id', ForeignKey('t1.id'))
+ )
+
+ def test_reflect_lowercase_forced_tables(self):
+
+ m2 = MetaData(testing.db)
+ t2_ref = Table(quoted_name('t2', quote=True), m2, autoload=True)
+ t1_ref = m2.tables['t1']
+ assert t2_ref.c.t1id.references(t1_ref.c.id)
+
+ m3 = MetaData(testing.db)
+ m3.reflect(only=lambda name, m: name.lower() in ('t1', 't2'))
+ assert m3.tables['t2'].c.t1id.references(m3.tables['t1'].c.id)
+
+ def test_get_table_names(self):
+ tablenames = [
+ t for t in inspect(testing.db).get_table_names()
+ if t.lower() in ("t1", "t2")]
+
+ eq_(tablenames[0].upper(), tablenames[0].lower())
+ eq_(tablenames[1].upper(), tablenames[1].lower())
+
+
+__all__ = ('ComponentReflectionTest', 'HasTableTest', 'NormalizedNameTest')