fix: quote tdengine history inserts
This commit is contained in:
@@ -45,6 +45,13 @@ func TestWriterAppendsRawLocationAndMileage(t *testing.T) {
|
||||
if got := countSQL(exec.calls, "INSERT INTO mil_"); got != 1 {
|
||||
t.Fatalf("mileage insert count = %d", got)
|
||||
}
|
||||
rawInsert := findSQL(exec.calls, "INSERT INTO raw_")
|
||||
if !strings.Contains(rawInsert, "'go_") || !strings.Contains(rawInsert, "'2e") && !strings.Contains(rawInsert, "'") {
|
||||
t.Fatalf("raw insert should quote string literals: %s", rawInsert)
|
||||
}
|
||||
if strings.Contains(rawInsert, "VALUES (?,") {
|
||||
t.Fatalf("raw insert should not use placeholders for tdengine websocket plain insert: %s", rawInsert)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterSkipsSparseDerivedRows(t *testing.T) {
|
||||
@@ -103,6 +110,15 @@ func countSQL(calls []execCall, pattern string) int {
|
||||
return count
|
||||
}
|
||||
|
||||
func findSQL(calls []execCall, pattern string) string {
|
||||
for _, call := range calls {
|
||||
if strings.Contains(call.query, pattern) {
|
||||
return call.query
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type execCall struct {
|
||||
query string
|
||||
args []any
|
||||
|
||||
Reference in New Issue
Block a user