@@ -39,7 +39,7 @@ func (p *Populator) generateCondition(keys []string, data map[string]interface{}
3939 var args []interface {}
4040 for _ , key := range keys {
4141 if v , ok := data [key ]; ok {
42- conditions = append (conditions , fmt .Sprintf ("%s=%s" , key , p .getPlaceholder ()))
42+ conditions = append (conditions , fmt .Sprintf ("%s=%s" , surroundKeyWithQuote ( key , p . Driver ) , p .getPlaceholder ()))
4343 args = append (args , v )
4444 } else {
4545 return "" , nil , fmt .Errorf ("key %s not found in record %v" , key , data )
@@ -49,7 +49,8 @@ func (p *Populator) generateCondition(keys []string, data map[string]interface{}
4949}
5050
5151func (p * Populator ) generateSelectQuery (fixture Fixture ) (string , []interface {}, error ) {
52- query := fmt .Sprintf ("SELECT %s FROM %s WHERE " , strings .Join (fixture .Keys , ", " ), fixture .TableName )
52+ quotedKeys := surroundKeysWithQuotes (fixture .Keys , p .Driver )
53+ query := fmt .Sprintf ("SELECT %s FROM %s WHERE " , strings .Join (quotedKeys , ", " ), fixture .TableName )
5354 var conditions []string
5455 var args []interface {}
5556 for _ , data := range fixture .Data {
@@ -87,7 +88,8 @@ func (p *Populator) generateInsertStmt(fixture Fixture, data []map[string]interf
8788 args = append (args , recordArgs ... )
8889 }
8990 values := strings .Join (placeholders , "," )
90- return fmt .Sprintf (query , fixture .TableName , strings .Join (keys , "," ), values ), args
91+ quotedKeys := surroundKeysWithQuotes (keys , p .Driver )
92+ return fmt .Sprintf (query , fixture .TableName , strings .Join (quotedKeys , "," ), values ), args
9193}
9294
9395func (p * Populator ) getExistingData (fixture Fixture ) ([]map [string ]interface {}, error ) {
0 commit comments