diff --git a/internal/storage/active_reconcile.go b/internal/storage/active_reconcile.go index f0ef7a6..783e416 100644 --- a/internal/storage/active_reconcile.go +++ b/internal/storage/active_reconcile.go @@ -666,11 +666,11 @@ GROUP BY d.sys_origin, d.country_code`, statTimezone, statTimezone, sysOrigin, s } func inPlaceholders(count int) string { - return "(" + placeholders(count, 1) + ")" + return "(" + strings.TrimRight(strings.Repeat("?,", count), ",") + ")" } func inStringPlaceholders(count int) string { - return "(" + placeholders(count, 1) + ")" + return inPlaceholders(count) } func stringArgs(values []string) []interface{} { diff --git a/internal/storage/placeholders_test.go b/internal/storage/placeholders_test.go new file mode 100644 index 0000000..cf1b0cd --- /dev/null +++ b/internal/storage/placeholders_test.go @@ -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) + } + }) + } +}