Skip to content

Commit 00ab012

Browse files
authored
fix: double quoted string literals in migrator (go-gorm#183)
1 parent 87158cf commit 00ab012

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

migrator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ func (m Migrator) GetIndexes(value interface{}) ([]gorm.Index, error) {
339339
indexes := make([]gorm.Index, 0)
340340
err := m.RunWithValue(value, func(stmt *gorm.Statement) error {
341341
rst := make([]*Index, 0)
342-
if err := m.DB.Debug().Raw(fmt.Sprintf("PRAGMA index_list(%q)", stmt.Table)).Scan(&rst).Error; err != nil {
342+
if err := m.DB.Debug().Raw("SELECT * FROM PRAGMA_index_list(?)", stmt.Table).Scan(&rst).Error; err != nil { // alias `PRAGMA index_list(?)`
343343
return err
344344
}
345345
for _, index := range rst {
346346
if index.Origin == "u" { // skip the index was created by a UNIQUE constraint
347347
continue
348348
}
349349
var columns []string
350-
if err := m.DB.Raw(fmt.Sprintf("SELECT name from PRAGMA_index_info(%q)", index.Name)).Scan(&columns).Error; err != nil { // alias `PRAGMA index_info(?)`
350+
if err := m.DB.Raw("SELECT name FROM PRAGMA_index_info(?)", index.Name).Scan(&columns).Error; err != nil { // alias `PRAGMA index_info(?)`
351351
return err
352352
}
353353
indexes = append(indexes, &migrator.Index{

0 commit comments

Comments
 (0)