Skip to content

Commit

Permalink
wrapped literal bug fix (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
djpalm801 committed Apr 29, 2024
1 parent 01efddb commit 95952a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,19 @@ func TestQueryLiteralQ(t *testing.T) {
}
}

func TestQueryLiteralQWrapped(t *testing.T) {
q := New("WHERE ??| = ?", "asdf")
wrapped := New("?", q)
sql, _, err := wrapped.ToPgsql()
if err != nil {
t.Errorf("got error from ToPgsql(): %v", err)
}
want := "WHERE ?| = $1"
if want != sql {
t.Errorf("got: %q, want:%q", sql, want)
}
}

func TestQueryNil(t *testing.T) {
var q *Query
q2 := New("test ?", q)
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func makePart(text string, args ...any) QueryPart {
errs = append(errs, argErrs...)
}
newArgs = append(newArgs, fArgs...)
text = argText
text = strings.ReplaceAll(argText, "??", tempPh)
}

if err := checkParamCounts(text, originalText, newArgs); err != nil {
Expand Down

0 comments on commit 95952a4

Please sign in to comment.