Skip to content

Commit faa6ccd

Browse files
fix: remove EXPRESSION column dependency in get_indexes_sql()
The EXPRESSION column in information_schema.STATISTICS only exists in MySQL 8.0.13+. Using it breaks @Schema decoration on MySQL < 8.0.13 and MariaDB. Use COLUMN_NAME directly; functional indexes with NULL column names are already filtered out downstream. Fixes #1436
1 parent dacf5ce commit faa6ccd

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/datajoint/adapters/mysql.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,14 @@ def parse_foreign_key_error(self, error_message: str) -> dict[str, str | list[st
737737
def get_indexes_sql(self, schema_name: str, table_name: str) -> str:
738738
"""Query to get index definitions.
739739
740-
Note: For MySQL 8.0+, EXPRESSION column contains the expression for
741-
functional indexes. COLUMN_NAME is NULL for such indexes.
740+
Uses COLUMN_NAME only for compatibility with MySQL < 8.0.13 and MariaDB,
741+
which lack the EXPRESSION column in information_schema.STATISTICS.
742+
Functional indexes (MySQL 8.0.13+) will have COLUMN_NAME = NULL and are
743+
filtered out downstream.
742744
"""
743745
return (
744746
f"SELECT INDEX_NAME as index_name, "
745-
f"COALESCE(COLUMN_NAME, CONCAT('(', EXPRESSION, ')')) as column_name, "
747+
f"COLUMN_NAME as column_name, "
746748
f"NON_UNIQUE as non_unique, SEQ_IN_INDEX as seq_in_index "
747749
f"FROM information_schema.statistics "
748750
f"WHERE table_schema = {self.quote_string(schema_name)} "

0 commit comments

Comments
 (0)