You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: enforce case-sensitive model name matching in MySQL
- Add case-sensitive collation (utf8mb4_bin) to model_name and ability.model columns
- Update IsModelNameDuplicated to use BINARY comparison for MySQL
- Add automatic migration to update existing MySQL databases
- PostgreSQL and SQLite remain case-sensitive by default
Fixes#1990
// fixModelNameCollation updates the model_name column to use case-sensitive collation in MySQL
250
+
funcfixModelNameCollation() error {
251
+
if!common.UsingMySQL {
252
+
returnnil// Only needed for MySQL
253
+
}
254
+
255
+
// Fix models.model_name column
256
+
varmodelCollationstring
257
+
err:=DB.Raw("SELECT COLLATION_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'models' AND COLUMN_NAME = 'model_name'").Scan(&modelCollation).Error
258
+
iferr!=nil {
259
+
// Table might not exist yet, ignore error
260
+
common.SysLog(fmt.Sprintf("Could not check models.model_name collation: %v", err))
err=DB.Raw("SELECT COLLATION_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'abilities' AND COLUMN_NAME = 'model'").Scan(&abilityCollation).Error
273
+
iferr!=nil {
274
+
// Table might not exist yet, ignore error
275
+
common.SysLog(fmt.Sprintf("Could not check abilities.model collation: %v", err))
0 commit comments