Skip to content

Commit b4d54c1

Browse files
committed
checkcheck
1 parent c03ef25 commit b4d54c1

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

api/models/efp_schemas.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ def _simple_schema(
217217
if "probeset_nullable" in kwargs:
218218
overrides.setdefault("data_probeset_id", {})["nullable"] = kwargs.pop("probeset_nullable")
219219

220+
# Build index list, excluding TEXT columns (can't be indexed in MySQL)
221+
index_columns = list(DEFAULT_INDEX)
222+
if "data_probeset_id" in overrides and overrides["data_probeset_id"].get("type") == "text":
223+
index_columns = [col for col in index_columns if col != "data_probeset_id"]
224+
if "data_bot_id" in overrides and overrides["data_bot_id"].get("type") == "text":
225+
index_columns = [col for col in index_columns if col != "data_bot_id"]
226+
227+
# Allow manual index override if specified
228+
if "index" not in kwargs:
229+
kwargs["index"] = index_columns
230+
220231
return EfpSchemaBuilder._build_schema(
221232
charset=charset,
222233
column_overrides=overrides,
@@ -261,13 +272,18 @@ def _schema_with_qa_columns(
261272
extra_columns = kwargs.pop("extra_columns", [])
262273
all_extra_cols = qa_cols + extra_columns
263274

275+
# Build index list - exclude data_probeset_id if it's TEXT type
276+
index_columns = ["data_probeset_id"]
277+
if kwargs.get("probeset_type") == "text":
278+
index_columns = []
279+
264280
return EfpSchemaBuilder._simple_schema(
265281
species=species,
266282
sample_regex=sample_regex,
267283
probeset_len=probeset_len,
268284
bot_id_len=bot_id_len,
269285
extra_columns=all_extra_cols,
270-
index=["data_probeset_id"],
286+
index=index_columns,
271287
**kwargs,
272288
)
273289

api/services/efp_bootstrap.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def _build_table(metadata: MetaData, spec, db_name: str) -> Table:
7373

7474
table = Table(spec["table_name"], metadata, *columns, mysql_charset=spec.get("charset"))
7575
index_cols = spec.get("index") or []
76+
if index_cols:
77+
# MySQL cannot index TEXT/BLOB columns without a prefix length.
78+
# Filter them out to avoid bootstrap failures when schemas use TEXT.
79+
text_cols = {col["name"] for col in spec["columns"] if col.get("type") == "text"}
80+
index_cols = [col for col in index_cols if col not in text_cols]
7681
if index_cols:
7782
index_name = _make_index_name(db_name, index_cols)
7883
Index(index_name, *[table.c[col] for col in index_cols])

0 commit comments

Comments
 (0)