MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestExtractFunctions_StringFunctions

Function TestExtractFunctions_StringFunctions

pkg/gosqlx/extract_test.go:478–490  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

476}
477
478func TestExtractFunctions_StringFunctions(t *testing.T) {
479 sql := "SELECT UPPER(name), LOWER(email), SUBSTRING(address, 1, 10) FROM users"
480 astNode, err := Parse(sql)
481 if err != nil {
482 t.Fatalf("Failed to parse SQL: %v", err)
483 }
484
485 functions := ExtractFunctions(astNode)
486 expected := []string{"UPPER", "LOWER", "SUBSTRING"}
487 if !stringSlicesEqual(functions, expected) {
488 t.Errorf("Expected functions %v, got %v", expected, functions)
489 }
490}
491
492func TestExtractFunctions_NestedFunctions(t *testing.T) {
493 sql := "SELECT UPPER(TRIM(name)) FROM users"

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.85
ExtractFunctionsFunction · 0.85
stringSlicesEqualFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected