fix dashboard SQL placeholders
This commit is contained in:
parent
24893460bc
commit
289ee7316b
@ -666,11 +666,11 @@ GROUP BY d.sys_origin, d.country_code`, statTimezone, statTimezone, sysOrigin, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
func inPlaceholders(count int) string {
|
func inPlaceholders(count int) string {
|
||||||
return "(" + placeholders(count, 1) + ")"
|
return "(" + strings.TrimRight(strings.Repeat("?,", count), ",") + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
func inStringPlaceholders(count int) string {
|
func inStringPlaceholders(count int) string {
|
||||||
return "(" + placeholders(count, 1) + ")"
|
return inPlaceholders(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringArgs(values []string) []interface{} {
|
func stringArgs(values []string) []interface{} {
|
||||||
|
|||||||
25
internal/storage/placeholders_test.go
Normal file
25
internal/storage/placeholders_test.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package storage
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestInPlaceholdersUsesScalarList(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
count int
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{name: "single", count: 1, want: "(?)"},
|
||||||
|
{name: "multiple", count: 3, want: "(?,?,?)"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := inPlaceholders(tt.count); got != tt.want {
|
||||||
|
t.Fatalf("inPlaceholders(%d) = %q, want %q", tt.count, got, tt.want)
|
||||||
|
}
|
||||||
|
if got := inStringPlaceholders(tt.count); got != tt.want {
|
||||||
|
t.Fatalf("inStringPlaceholders(%d) = %q, want %q", tt.count, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user