"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):