-
-
Notifications
You must be signed in to change notification settings - Fork 143
Closed
Description
When table or field comments contain '
single quotes, using logger.ExplainSQL
may lead to syntax errors due to the single quotes being escaped using MySQL's syntax \'
in the SQL statements.
COMMENT ON COLUMN "users"."name" IS 'user\'s name'
ERROR: syntax error at or near "s" (SQLSTATE 42601)
Lines 167 to 174 in 68a877c
if field.Comment != "" { | |
if err := m.DB.Exec( | |
"COMMENT ON COLUMN ?.? IS ?", | |
m.CurrentTable(stmt), clause.Column{Name: field.DBName}, gorm.Expr(m.Migrator.Dialector.Explain("$1", field.Comment)), | |
).Error; err != nil { | |
return err | |
} | |
} |
Lines 216 to 223 in 68a877c
if field.Comment != "" { | |
if err := m.DB.Exec( | |
"COMMENT ON COLUMN ?.? IS ?", | |
m.CurrentTable(stmt), clause.Column{Name: field.DBName}, gorm.Expr(m.Migrator.Dialector.Explain("$1", field.Comment)), | |
).Error; err != nil { | |
return err | |
} | |
} |
Lines 270 to 277 in 68a877c
if field.Comment != "" && comment != description { | |
if err := m.DB.Exec( | |
"COMMENT ON COLUMN ?.? IS ?", | |
m.CurrentTable(stmt), clause.Column{Name: field.DBName}, gorm.Expr(m.Migrator.Dialector.Explain("$1", field.Comment)), | |
).Error; err != nil { | |
return err | |
} | |
} |
Metadata
Metadata
Assignees
Labels
No labels