Skip to content

Group single-quoted literals with implicit aliases - #926

Draft
vhinayindia wants to merge 1 commit into
andialbrecht:masterfrom
vhinayindia:fix-string-literal-alias-518
Draft

vhinayindia wants to merge 1 commit into
andialbrecht:masterfrom
vhinayindia:fix-string-literal-alias-518

Conversation

@vhinayindia

Copy link
Copy Markdown

Fixes #518.

Single-quoted literals with an implicit alias are left outside the projection list. For example, SELECT 'fixed_text' alias1, field1, field2 FROM tbl aligns the following columns under alias1 rather than under the complete first expression. A literal in the middle can split the projection into two lists.

Include String.Single in the existing implicit-alias grouping pass, retaining its requirement that the next significant token is an Identifier. Bare and adjacent strings remain literal tokens, preserving #111's behavior. Numeric aliases continue to match all Number subtypes.

The tests cover projection positions, nested SELECTs, empty/escaped/multiline strings, quoted aliases, parent links, round trips, and repeated reindent formatting. This is limited to single-quoted literal aliases; it does not extend prefixed or typed literals, comment-separated aliases, or dialect-specific alias grammar.

Validation on Linux:

  • Full suite on Python 3.10.21, 3.11.16, 3.12.14, 3.13.5 and 3.14.7: 533 passed, 2 xfailed, 1 xpassed on each. The xfail/xpass counts match untouched upstream.

  • Identical focused tests: 16 failed, 12 passed on untouched source; 28 passed with the fix.

  • make lint and git diff --check pass.

  • The repository grouping benchmark and a bounded string-alias projection benchmark report linear scaling before and after.

  • Additional SQLite checks preserve result rows and column names across formatting; these do not establish behavior for every SQL dialect. Windows/macOS and hosted CI have not been run locally.

  • ran the tests (pytest)

  • all style issues addressed (ruff)

  • changes covered by tests

  • changelog updated; no public API changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single quoted literal with alias generates wrong tokens

1 participant