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 authored and mmlb committed Feb 8, 2022
1 parent 2be823c commit 23f3466
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 23f3466

Please sign in to comment.