Skip to content

Commit

Permalink
Merge pull request jmoiron#152 from vibbix/patch-1
Browse files Browse the repository at this point in the history
unit test for colons
  • Loading branch information
jmoiron authored Jan 24, 2021
2 parents 549f10b + 029d352 commit 0a02cfe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions named_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ func (t Test) Errorf(err error, format string, args ...interface{}) {
}
}

func TestEscapedColons(t *testing.T) {
var qs = `SELECT * FROM testtable WHERE timeposted BETWEEN (now() AT TIME ZONE 'utc') AND
(now() AT TIME ZONE 'utc') - interval '01:30:00') AND name = '\'this is a test\'' and id = :id`
_, _, err := compileNamedQuery([]byte(qs), 3) //3 being DOLLAR
if err != nil{
t.Error("Didn't handle colons correctly when inside a string")
}
}

func TestNamedQueries(t *testing.T) {
RunWithSchema(defaultSchema, t, func(db *DB, t *testing.T, now string) {
loadDefaultFixture(db, t)
Expand Down

0 comments on commit 0a02cfe

Please sign in to comment.