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

Function TestTypesCasting

tests/integration/types_test.go:283–301  ·  view source on GitHub ↗

TestTypesCasting tests type casting

(t *testing.T)

Source from the content-addressed store, hash-verified

281 }
282 runQueryTests(t, tests)
283}
284
285// TestTypesCasting tests type casting
286func TestTypesCasting(t *testing.T) {
287 tests := []QueryTest{
288 // CAST syntax
289 {Name: "cast_int_to_text", Query: "SELECT CAST(123 AS TEXT)"},
290 {Name: "cast_text_to_int", Query: "SELECT CAST('123' AS INTEGER)"},
291 {Name: "cast_float_to_int", Query: "SELECT CAST(3.7 AS INTEGER)"},
292 {Name: "cast_bool_to_int", Query: "SELECT CAST(TRUE AS INTEGER)"},
293
294 // :: syntax
295 {Name: "colon_int_to_text", Query: "SELECT 123::TEXT"},
296 {Name: "colon_text_to_int", Query: "SELECT '123'::INTEGER"},
297 {Name: "colon_timestamp", Query: "SELECT '2024-01-15 12:30:45'::TIMESTAMP"},
298
299 // Implicit casting
300 {Name: "implicit_int_to_float", Query: "SELECT 1 + 1.5"},
301 {Name: "implicit_concat", Query: "SELECT 'count: ' || 5"},
302 }
303 runQueryTests(t, tests)
304}

Callers

nothing calls this directly

Calls 1

runQueryTestsFunction · 0.85

Tested by

no test coverage detected