MCPcopy
hub / github.com/sqldef/sqldef / TestInvalidCustomOperators

Function TestInvalidCustomOperators

parser/parser_test.go:702–738  ·  view source on GitHub ↗

TestInvalidCustomOperators tests that invalid PostgreSQL custom operators produce errors

(t *testing.T)

Source from the content-addressed store, hash-verified

700
701// TestInvalidCustomOperators tests that invalid PostgreSQL custom operators produce errors
702func TestInvalidCustomOperators(t *testing.T) {
703 testCases := []struct {
704 name string
705 sql string
706 description string
707 }{
708 {
709 name: "Operator containing --",
710 sql: "CREATE VIEW v AS SELECT a <-- b FROM t",
711 description: "Operators cannot contain -- (comment sequence)",
712 },
713 {
714 name: "Operator containing /*",
715 sql: "CREATE VIEW v AS SELECT a </* b FROM t",
716 description: "Operators cannot contain /* (comment sequence)",
717 },
718 {
719 name: "Operator ending in - without special char",
720 sql: "CREATE VIEW v AS SELECT a <- b FROM t",
721 description: "Multi-char operators ending in - must contain ~ ! @ # % ^ & | ` ?",
722 },
723 {
724 name: "Operator ending in + without special char",
725 sql: "CREATE VIEW v AS SELECT a <+ b FROM t",
726 description: "Multi-char operators ending in + must contain ~ ! @ # % ^ & | ` ?",
727 },
728 }
729
730 for _, tc := range testCases {
731 t.Run(tc.name, func(t *testing.T) {
732 _, err := ParseDDL(tc.sql, ParserModePostgres)
733 if err == nil {
734 t.Errorf("Expected parse error but got none.\n%s\nSQL: %s", tc.description, tc.sql)
735 }
736 })
737 }
738}
739
740func TestDefaultFunctionExpressions(t *testing.T) {
741 testCases := []struct {

Callers

nothing calls this directly

Calls 2

ParseDDLFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected