Skip to content

Commit

Permalink
escape pgsql field and values generated by buildGetCondition
Browse files Browse the repository at this point in the history
Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Jan 12, 2022
1 parent b18b238 commit ef69e41
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func get(ctx context.Context, db *sql.DB, query string, args ...interface{}) (st
func buildGetCondition(fields map[string]string) (string, error) {
for column, field := range fields {
if field != "" {
return fmt.Sprintf("%s = '%s'", column, field), nil
return fmt.Sprintf("%s = %s", pq.QuoteIdentifier(column), pq.QuoteLiteral(field)), nil
}
}
return "", errors.New("one GetBy field must be set to build a get condition")
Expand Down

0 comments on commit ef69e41

Please sign in to comment.