package sqlutil import "testing" func TestIdentQuoting(t *testing.T) { if got := Ident("a`b"); got != "`a``b`" { t.Fatalf("got %s", got) } if got := Qualified("db", "t"); got != "`db`.`t`" { t.Fatalf("got %s", got) } if got := Qualified("", "t"); got != "`t`" { t.Fatalf("got %s", got) } } func TestGreaterThan(t *testing.T) { if got := GreaterThan([]string{"id"}); got != "`id` > ?" { t.Fatalf("got %s", got) } if got := GreaterThan([]string{"a", "b"}); got != "(`a`, `b`) > (?, ?)" { t.Fatalf("got %s", got) } } func TestInList(t *testing.T) { if got := InList([]string{"id"}, 3); got != "`id` IN (?, ?, ?)" { t.Fatalf("got %s", got) } if got := InList([]string{"a", "b"}, 2); got != "(`a`, `b`) IN ((?, ?), (?, ?))" { t.Fatalf("got %s", got) } if got := InList([]string{"id"}, 0); got != "1=0" { t.Fatalf("got %s", got) } }