| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1267,33 +1267,36 @@ def get_multi_indexes( | |||
| 1267 | 1267 | i.table_schema, | |
| 1268 | 1268 | i.table_name, | |
| 1269 | 1269 | i.index_name, | |
| 1270 | - ( | ||
| 1271 | - SELECT ARRAY_AGG(ic.column_name) | ||
| 1270 | + ARRAY( | ||
| 1271 | + SELECT ic.column_name | ||
| 1272 | 1272 | FROM information_schema.index_columns ic | |
| 1273 | 1273 | WHERE ic.index_name = i.index_name | |
| 1274 | 1274 | AND ic.table_catalog = i.table_catalog | |
| 1275 | 1275 | AND ic.table_schema = i.table_schema | |
| 1276 | 1276 | AND ic.table_name = i.table_name | |
| 1277 | 1277 | AND ic.column_ordering is not null | |
| 1278 | + ORDER BY ic.ordinal_position | ||
| 1278 | 1279 | ) as columns, | |
| 1279 | 1280 | i.is_unique, | |
| 1280 | - ( | ||
| 1281 | - SELECT ARRAY_AGG(ic.column_ordering) | ||
| 1281 | + ARRAY( | ||
| 1282 | + SELECT ic.column_ordering | ||
| 1282 | 1283 | FROM information_schema.index_columns ic | |
| 1283 | 1284 | WHERE ic.index_name = i.index_name | |
| 1284 | 1285 | AND ic.table_catalog = i.table_catalog | |
| 1285 | 1286 | AND ic.table_schema = i.table_schema | |
| 1286 | 1287 | AND ic.table_name = i.table_name | |
| 1287 | 1288 | AND ic.column_ordering is not null | |
| 1289 | + ORDER BY ic.ordinal_position | ||
| 1288 | 1290 | ) as column_orderings, | |
| 1289 | - ( | ||
| 1290 | - SELECT ARRAY_AGG(storing.column_name) | ||
| 1291 | + ARRAY( | ||
| 1292 | + SELECT storing.column_name | ||
| 1291 | 1293 | FROM information_schema.index_columns storing | |
| 1292 | 1294 | WHERE storing.index_name = i.index_name | |
| 1293 | 1295 | AND storing.table_catalog = i.table_catalog | |
| 1294 | 1296 | AND storing.table_schema = i.table_schema | |
| 1295 | 1297 | AND storing.table_name = i.table_name | |
| 1296 | 1298 | AND storing.column_ordering is null | |
| 1299 | + ORDER BY storing.ordinal_position | ||
| 1297 | 1300 | ) as storing_columns, | |
| 1298 | 1301 | FROM information_schema.indexes as i | |
| 1299 | 1302 | JOIN information_schema.tables AS t | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,7 +106,7 @@ def define_tables(cls, metadata): | |||
| 106 | 106 | Column("a", String, primary_key=True), | |
| 107 | 107 | Column("b", String, primary_key=True), | |
| 108 | 108 | ) | |
| 109 | - Table( | ||
| 109 | + composite_fk = Table( | ||
| 110 | 110 | "composite_fk", | |
| 111 | 111 | metadata, | |
| 112 | 112 | Column("my_a", String, primary_key=True), | |
@@ -118,6 +118,12 @@ def define_tables(cls, metadata): | |||
| 118 | 118 | name="composite_fk_composite_pk_a_b", | |
| 119 | 119 | ), | |
| 120 | 120 | ) | |
| 121 | + Index( | ||
| 122 | + "idx_composte_fk_all", | ||
| 123 | + composite_fk.c.my_a, | ||
| 124 | + composite_fk.c.my_b, | ||
| 125 | + composite_fk.c.my_c, | ||
| 126 | + ) | ||
| 121 | 127 | ||
| 122 | 128 | def test_hello_world(self, connection): | |
| 123 | 129 | greeting = connection.execute(text("select 'Hello World'")) | |
@@ -356,6 +362,28 @@ def test_composite_fk_lookups(self, connection): | |||
| 356 | 362 | insp.get_multi_foreign_keys(filter_names=["composite_fk"]), | |
| 357 | 363 | ) | |
| 358 | 364 | ||
| 365 | + def test_composite_index_lookups(self, connection): | ||
| 366 | + """Ensures we introspect composite indexes.""" | ||
| 367 | + | ||
| 368 | + engine = connection.engine | ||
| 369 | + | ||
| 370 | + insp = inspect(engine) | ||
| 371 | + eq_( | ||
| 372 | + { | ||
| 373 | + (None, "composite_fk"): [ | ||
| 374 | + { | ||
| 375 | + "name": "idx_composte_fk_all", | ||
| 376 | + "column_names": ["my_a", "my_b", "my_c"], | ||
| 377 | + "unique": False, | ||
| 378 | + "column_sorting": {"my_a": "asc", "my_b": "asc", "my_c": "asc"}, | ||
| 379 | + "include_columns": [], | ||
| 380 | + "dialect_options": {}, | ||
| 381 | + } | ||
| 382 | + ] | ||
| 383 | + }, | ||
| 384 | + insp.get_multi_indexes(filter_names=["composite_fk"]), | ||
| 385 | + ) | ||
| 386 | + | ||
| 359 | 387 | def test_commit_timestamp(self, connection): | |
| 360 | 388 | """Ensures commit timestamps are set.""" | |
| 361 | 389 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments