diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2019-01-10 02:07:24 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2019-01-10 02:07:24 +0000 |
commit | f1706ae317ab5e3b263420e6218696821fbcd878 (patch) | |
tree | 5f40d93bf4e5064fb0f37897fab6d06d4c78ee48 /lib/sqlalchemy/testing | |
parent | 2a840c147e49d833f8a11de3964a0a8588d72508 (diff) | |
parent | 08994cb97c501a3cf984fd827eba9aa9614b9dd3 (diff) | |
download | sqlalchemy-f1706ae317ab5e3b263420e6218696821fbcd878.tar.gz |
Merge "Skip expression-based index reflection for SQLite"
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r-- | lib/sqlalchemy/testing/requirements.py | 5 | ||||
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_reflection.py | 30 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 941a9458b..ce9954cfd 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -454,6 +454,11 @@ class SuiteRequirements(Requirements): return exclusions.open() @property + def indexes_with_expressions(self): + """target database supports CREATE INDEX against SQL expressions.""" + return exclusions.closed() + + @property def unique_constraint_reflection(self): """target dialect supports reflection of unique constraints""" return exclusions.open() diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index 96bd188ee..d589c046f 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -6,6 +6,7 @@ from .. import assert_raises_message from .. import config from .. import engines from .. import eq_ +from .. import expect_warnings from .. import fixtures from .. import is_ from ..schema import Column @@ -792,6 +793,35 @@ class ComponentReflectionTest(fixtures.TablesTest): def test_get_noncol_index_pk(self): self._test_get_noncol_index("noncol_idx_test_pk", "noncol_idx_pk") + @testing.requires.indexes_with_expressions + @testing.provide_metadata + def test_reflect_expression_based_indexes(self): + Table( + "t", + self.metadata, + Column("x", String(30)), + Column("y", String(30)), + ) + event.listen( + self.metadata, + "after_create", + DDL("CREATE INDEX t_idx ON t(lower(x), lower(y))"), + ) + event.listen( + self.metadata, "after_create", DDL("CREATE INDEX t_idx_2 ON t(x)") + ) + self.metadata.create_all() + + insp = inspect(self.metadata.bind) + + with expect_warnings( + "Skipped unsupported reflection of expression-based index t_idx" + ): + eq_( + insp.get_indexes("t"), + [{"name": "t_idx_2", "column_names": ["x"], "unique": 0}], + ) + @testing.requires.unique_constraint_reflection def test_get_unique_constraints(self): self._test_get_unique_constraints() |