Skip to content

Commit 0a02cfe

Browse files
authored
Merge pull request jmoiron#152 from vibbix/patch-1
unit test for colons
2 parents 549f10b + 029d352 commit 0a02cfe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

named_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ func (t Test) Errorf(err error, format string, args ...interface{}) {
119119
}
120120
}
121121

122+
func TestEscapedColons(t *testing.T) {
123+
var qs = `SELECT * FROM testtable WHERE timeposted BETWEEN (now() AT TIME ZONE 'utc') AND
124+
(now() AT TIME ZONE 'utc') - interval '01:30:00') AND name = '\'this is a test\'' and id = :id`
125+
_, _, err := compileNamedQuery([]byte(qs), 3) //3 being DOLLAR
126+
if err != nil{
127+
t.Error("Didn't handle colons correctly when inside a string")
128+
}
129+
}
130+
122131
func TestNamedQueries(t *testing.T) {
123132
RunWithSchema(defaultSchema, t, func(db *DB, t *testing.T, now string) {
124133
loadDefaultFixture(db, t)

0 commit comments

Comments
 (0)