summaryrefslogtreecommitdiff
path: root/test/engine/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-09-02 14:18:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-09-02 14:18:09 -0400
commitec840a6eea05ac031a55d262dc370bed942b2212 (patch)
tree9cd73f0a285fad400ca0e25cff6eccbf57d31af2 /test/engine/test_reflection.py
parent9ee89dc88671a8c5d005c5baf3b2a7be58fee8ed (diff)
downloadsqlalchemy-ec840a6eea05ac031a55d262dc370bed942b2212.tar.gz
- An adjustment to table/index reflection such that if an index
reports a column that isn't found to be present in the table, a warning is emitted and the column is skipped. This can occur for some special system column situations as has been observed with Oracle. fixes #3180
Diffstat (limited to 'test/engine/test_reflection.py')
-rw-r--r--test/engine/test_reflection.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py
index 807abc84f..c18b8b944 100644
--- a/test/engine/test_reflection.py
+++ b/test/engine/test_reflection.py
@@ -983,6 +983,26 @@ class ReflectionTest(fixtures.TestBase, ComparesTables):
assert set([t2.c.name, t2.c.id]) == set(r2.columns)
assert set([t2.c.name]) == set(r3.columns)
+ @testing.provide_metadata
+ def test_index_reflection_cols_busted(self):
+ t = Table('x', self.metadata,
+ Column('a', Integer), Column('b', Integer))
+ sa.Index('x_ix', t.c.a, t.c.b)
+ self.metadata.create_all()
+
+ def mock_get_columns(self, connection, table_name, **kw):
+ return [
+ {"name": "b", "type": Integer, "primary_key": False}
+ ]
+
+ with testing.mock.patch.object(
+ testing.db.dialect, "get_columns", mock_get_columns):
+ m = MetaData()
+ with testing.expect_warnings(
+ "index key 'a' was not located in columns"):
+ t = Table('x', m, autoload=True, autoload_with=testing.db)
+
+ eq_(list(t.indexes)[0].columns, [t.c.b])
@testing.requires.views
@testing.provide_metadata