Skip to content

Commit c03ef25

Browse files
committed
Fix TEXT columns in primary keys causing MySQL error
MySQL doesn't allow TEXT/BLOB columns in primary keys without a key length. When bot_id_type='text' or probeset_type='text' is specified, the column type changes to TEXT but was still marked as primary_key=True, causing: OperationalError: (1170, "BLOB/TEXT column 'data_bot_id' used in key specification without a key length") Changes: - In _simple_schema(), when probeset_type='text', set primary_key=False - In _simple_schema(), when bot_id_type='text', set primary_key=False - Ensures data_signal remains a primary key for all databases Affected databases (11 total): - affydb, canola, canola_original, canola_seed - hnahal, human, humandb - meristemdb, rohan, rpatel, tomato_atlas All 58 tests pass with 5,643 subtests.
1 parent a5d07a8 commit c03ef25

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

api/models/efp_schemas.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,19 @@ def _simple_schema(
173173
if "probeset_type" in kwargs:
174174
probeset_type = kwargs.pop("probeset_type")
175175
overrides["data_probeset_id"] = {"type": probeset_type, "length": None}
176+
# TEXT columns cannot be primary keys in MySQL
177+
if probeset_type == "text":
178+
overrides["data_probeset_id"]["primary_key"] = False
176179
else:
177180
overrides["data_probeset_id"] = {"length": probeset_len}
178181

179182
# Handle data_bot_id
180183
if "bot_id_type" in kwargs:
181184
bot_id_type = kwargs.pop("bot_id_type")
182185
overrides["data_bot_id"] = {"type": bot_id_type, "length": None}
186+
# TEXT columns cannot be primary keys in MySQL
187+
if bot_id_type == "text":
188+
overrides["data_bot_id"]["primary_key"] = False
183189
else:
184190
overrides["data_bot_id"] = {"length": bot_id_len}
185191

0 commit comments

Comments
 (0)