Fix where clauses for templates
This commit is contained in:
parent
89ec1cfdb7
commit
b1d1b30724
2 changed files with 6 additions and 6 deletions
|
@ -245,7 +245,7 @@ func GenerateParamFlags(colCount int, startAt int, groupAt int) string {
|
|||
|
||||
// WhereClause returns the where clause using start as the $ flag index
|
||||
// For example, if start was 2 output would be: "colthing=$2 AND colstuff=$3"
|
||||
func WhereClause(start int, cols ...string) string {
|
||||
func WhereClause(start int, cols []string) string {
|
||||
if start == 0 {
|
||||
panic("0 is not a valid start number for whereClause")
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ func WhereClause(start int, cols ...string) string {
|
|||
// WhereMultiple is a version of Where that binds multiple checks together
|
||||
// with an or statement.
|
||||
// WhereMultiple(1, 2, "a", "b") = "(a=$1 and b=$2) or (a=$3 and b=$4)"
|
||||
func WhereMultiple(start, count int, cols ...string) string {
|
||||
func WhereMultiple(start, count int, cols []string) string {
|
||||
if start == 0 {
|
||||
panic("0 is not a valid start number for whereMultiple")
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ func TestWhereClause(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
r := WhereClause(test.Start, test.Cols...)
|
||||
r := WhereClause(test.Start, test.Cols)
|
||||
if r != test.Should {
|
||||
t.Errorf("(%d) want: %s, got: %s\nTest: %#v", i, test.Should, r, test)
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ func TestWhereClausePanic(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
WhereClause(0)
|
||||
WhereClause(0, nil)
|
||||
}
|
||||
|
||||
func TestWhereMultiple(t *testing.T) {
|
||||
|
@ -349,7 +349,7 @@ func TestWhereMultiple(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
r := WhereMultiple(test.Start, test.Count, test.Cols...)
|
||||
r := WhereMultiple(test.Start, test.Count, test.Cols)
|
||||
if r != test.Should {
|
||||
t.Errorf("(%d) want: %s, got: %s", i, test.Should, r)
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ func TestWhereMultiplePanic(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
WhereMultiple(0, 0)
|
||||
WhereMultiple(0, 0, nil)
|
||||
}
|
||||
|
||||
func TestInClause(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue