]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
extend test case
authorTobias Pfeiffer <tgp@preferred.jp>
Wed, 16 Nov 2022 08:17:14 +0000 (17:17 +0900)
committerTobias Pfeiffer <tgp@preferred.jp>
Wed, 16 Nov 2022 08:17:14 +0000 (17:17 +0900)
test/dialect/test_sqlite.py

index 9ed5f64bac85922f7a3962343a4cf0967204faa2..a5e2bec4b7606be2d1fcd357c16b904d78eac2e6 100644 (file)
@@ -2313,22 +2313,47 @@ class ConstraintReflectionTest(fixtures.TestBase):
                 "create unique index ix_partial on "
                 "foo_with_partial_index (x) where y > 10"
             )
+            conn.exec_driver_sql(
+                "create unique index ix_no_partial on "
+                "foo_with_partial_index (x)"
+            )
+            conn.exec_driver_sql(
+                "create unique index ix_partial2 on "
+                "foo_with_partial_index (x, y) where "
+                "y = 10 or abs(x) < 5"
+            )
 
             inspector = inspect(conn)
             indexes = inspector.get_indexes("foo_with_partial_index")
             eq_(
                 indexes,
                 [
+                    {
+                        "unique": 1,
+                        "name": "ix_no_partial",
+                        "column_names": ["x"],
+                        "dialect_options": {},
+                    },
                     {
                         "unique": 1,
                         "name": "ix_partial",
                         "column_names": ["x"],
                         "dialect_options": {"sqlite_where": ANY},
-                    }
+                    },
+                    {
+                        "unique": 1,
+                        "name": "ix_partial2",
+                        "column_names": ["x", "y"],
+                        "dialect_options": {"sqlite_where": ANY},
+                    },
                 ],
             )
             assert (
-                indexes[0]["dialect_options"]["sqlite_where"].text == "y > 10"
+                indexes[1]["dialect_options"]["sqlite_where"].text == "y > 10"
+            )
+            assert (
+                indexes[2]["dialect_options"]["sqlite_where"].text
+                == "y = 10 or abs(x) < 5"
             )
 
     def test_unique_constraint_named(self):