Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2494 +/- ##
==========================================
- Coverage 81.09% 81.09% -0.01%
==========================================
Files 42 42
Lines 33684 33719 +35
Branches 33684 33719 +35
==========================================
+ Hits 27316 27344 +28
Misses 2798 2798
- Partials 3570 3577 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /// true if the expression uses the `SUBSTRING(expr SIMILAR pattern ESCAPE escape)` syntax, | ||
| /// in which case `substring_from` holds the pattern and `substring_for` holds the escape. | ||
| /// This flag is used for formatting. | ||
| similar: bool, |
There was a problem hiding this comment.
Would a single syntax enum be better here, replacing special and similar with one variant each for the comma, FROM/FOR, FOR/FROM and SIMILAR/ESCAPE forms? SUBSTRING('1' FOR 3 FROM 1) now prints as SUBSTRING('1' FROM 1 FOR 3), which breaks the round trip the README promises, and a third flag for the order would leave combinations such as special with similar representable.
| one_statement_parses_to( | ||
| "SELECT SUBSTRING('1' FOR 3 FROM 1)", | ||
| "SELECT SUBSTRING('1' FROM 1 FOR 3)", | ||
| ); |
There was a problem hiding this comment.
You may want to pin the reversed order as a round trip. On the current head it fails with left: "SELECT SUBSTRING('1' FOR 3 FROM 1)", right: "SELECT SUBSTRING('1' FROM 1 FOR 3)".
| one_statement_parses_to( | |
| "SELECT SUBSTRING('1' FOR 3 FROM 1)", | |
| "SELECT SUBSTRING('1' FROM 1 FOR 3)", | |
| ); | |
| verified_stmt("SELECT SUBSTRING('1' FOR 3 FROM 1)"); |
Fixes parsing of two legal Postgres
SUBSTRINGforms:SUBSTRING('hello world' FOR 5 FROM 1)(FORbeforeFROM)SUBSTRING('hello world' SIMILAR '%#"o w#"%' ESCAPE '#')See https://www.postgresql.org/docs/current/functions-string.html
Both previously failed with a parser error. Adds a
similarflag toExpr::Substringto track theSIMILAR ... ESCAPEdisplay form, and allowsFORto be parsed beforeFROM(normalized toFROM ... FORon output).Generated with AI assistance (GitHub Copilot).