TestInvalidCustomOperators tests that invalid PostgreSQL custom operators produce errors
(t *testing.T)
| 700 | |
| 701 | // TestInvalidCustomOperators tests that invalid PostgreSQL custom operators produce errors |
| 702 | func 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 | |
| 740 | func TestDefaultFunctionExpressions(t *testing.T) { |
| 741 | testCases := []struct { |