Skip to content

PostgreSQL: Reject string literals as aliases - #2668

Merged
LucaCappelletti94 merged 1 commit into
mainfrom
upstream/postgres-no-string-alias
Oct 18, 2026
Merged

LucaCappelletti94 merged 1 commit into
mainfrom
upstream/postgres-no-string-alias

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

PostgreSQL does not accept a single-quoted string as a column or table alias. The SELECT reference defines both as identifiers (https://www.postgresql.org/docs/current/sql-select.html), and PostgreSQL 16 rejects SELECT 1 AS 'x', SELECT 1 'x', SELECT a FROM t AS 'y' and SELECT a FROM t 'y' with a syntax error. The parser accepted a string alias in every dialect.

A new dialect method, supports_string_literal_alias, defaults to true so the other dialects are unchanged, and PostgreSqlDialect sets it to false. Tests check the exact errors for column and table aliases in PostgreSQL and that every other dialect still accepts both.

@LucaCappelletti94 LucaCappelletti94 added bug Something isn't working PostgreSQL labels Oct 17, 2026
@codecov-commenter

codecov-commenter commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.25%. Comparing base (1aabd12) to head (34037e1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2668   +/-   ##
=======================================
  Coverage   81.25%   81.25%           
=======================================
  Files          42       42           
  Lines       33910    33917    +7     
  Branches    33910    33917    +7     
=======================================
+ Hits        27553    27560    +7     
  Misses       2792     2792           
  Partials     3565     3565           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@s5dsn-eqee s5dsn-eqee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@LucaCappelletti94

Copy link
Copy Markdown
Contributor Author

Merging, thanks @s5dsn-eqee for the review!

cc @alamb @iffyio

@LucaCappelletti94
LucaCappelletti94 added this pull request to the merge queue Oct 18, 2026
Merged via the queue into main with commit 66e0e89 Oct 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants