2024-08-09 15:00:52 +00:00
|
|
|
package builder
|
2024-08-09 14:14:42 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConvertInsert(t *testing.T) {
|
2024-08-09 14:56:38 +00:00
|
|
|
ctx := SQLiteContext{
|
2024-08-09 14:14:42 +00:00
|
|
|
TableName: "test",
|
|
|
|
TableAlias: "t",
|
|
|
|
}
|
|
|
|
insert := []Map{
|
|
|
|
{"a": "1", "b": 2},
|
|
|
|
{"b": 2, "a": "1", "c": 3},
|
|
|
|
}
|
2024-08-09 22:33:10 +00:00
|
|
|
result, _ := convertInsert(ctx, insert)
|
2024-08-09 14:14:42 +00:00
|
|
|
|
|
|
|
if result.Statement != `INSERT INTO test (a,b,c) VALUES (?,?,?)` {
|
|
|
|
t.Errorf(`Expected "INSERT INTO test (a,b,c) VALUES (?,?,?)", got %s`, result.Statement)
|
|
|
|
}
|
|
|
|
|
2024-08-09 19:14:28 +00:00
|
|
|
// for _, r := range result.Values {
|
|
|
|
// fmt.Println(r)
|
|
|
|
// }
|
2024-08-09 14:14:42 +00:00
|
|
|
|
|
|
|
}
|