Skip to content

feat: allow SELECT without target expressions for PostgreSQL - #2841

Open
princejain756 wants to merge 3 commits into
JSQLParser:masterfrom
princejain756:pg-empty-select
Open

princejain756 wants to merge 3 commits into
JSQLParser:masterfrom
princejain756:pg-empty-select

Conversation

@princejain756

Copy link
Copy Markdown
Contributor

Resolves #2784.

PostgreSQL permits a SELECT with no target expressions, e.g.

SELECT FROM t
SELECT count(*) FROM (SELECT FROM (VALUES (1, 'a'), (2, 'b')) AS t(id, label)) AS q

which fails with a parse error because SelectItemsList requires at least one SelectItem.

With this change PlainSelect accepts an absent select-item list when the POSTGRESQL dialect is active and FROM follows SELECT directly. The parsed model exposes an empty select-items list rather than an UNSPECIFIC node, and both the toString path and SelectDeParser avoid emitting a doubled space in SELECT FROM when the list is empty. Other dialects and all existing SELECT forms are unchanged.

10,733 tests, 0 failures, 25 skipped.

Making the select-items group optional for the target-less PostgreSQL
SELECT let JavaCC see K_AS in the follow set of the optional AS
STRUCT/VALUE qualifier block, producing a choice conflict at the block.
Guard it with an explicit lookahead so AS only opens the qualifier when
STRUCT or VALUE comes next.

This branch has not been deployed

No deployments
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.

[BUG] JSQLParser : PostgreSQL : SELECT without target expressions fails to parse

1 participant