MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestFormatSQLValue

Function TestFormatSQLValue

server/ducklake/migration_test.go:233–262  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

231func intPtr(n int) *int { return &n }
232
233func TestFormatSQLValue(t *testing.T) {
234 tests := []struct {
235 name string
236 v any
237 want string
238 }{
239 {"nil", nil, "NULL"},
240 {"true", true, "TRUE"},
241 {"false", false, "FALSE"},
242 {"int", int64(42), "42"},
243 {"negative int", int64(-1), "-1"},
244 {"float", float64(3.14), "3.14"},
245 {"string", "hello", "'hello'"},
246 {"string with quote", "it's", "'it''s'"},
247 {"string with double quote", `say "hi"`, `'say "hi"'`},
248 {"empty string", "", "''"},
249 {"bytes", []byte("data"), "'data'"},
250 {"bytes with quote", []byte("it's"), "'it''s'"},
251 {"time", time.Date(2026, 3, 23, 12, 0, 0, 0, time.UTC), "'2026-03-23T12:00:00Z'"},
252 }
253
254 for _, tt := range tests {
255 t.Run(tt.name, func(t *testing.T) {
256 got := formatSQLValue(tt.v)
257 if got != tt.want {
258 t.Errorf("formatSQLValue(%v) = %s, want %s", tt.v, got, tt.want)
259 }
260 })
261 }
262}
263
264func TestQuoteIdent(t *testing.T) {
265 tests := []struct {

Callers

nothing calls this directly

Calls 2

formatSQLValueFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected