Skip to content

SQLite: Parentheses are currently omitted around set operations, leading to data corruption #36112

@roji

Description

@roji

Most databases allow parenthese around set operations to control evaluation order:

SELECT 1
INTERSECT
(
  SELECT 1
  EXCEPT
  SELECT 1
)

In SQLite, the above is a syntax error. As a result, we currently omit parentheses around set operations altogether (code), leading to data corruption in some cases.

However, SQLite does support simply wrapping the nested set operation in a SELECT:

SELECT 1
INTERSECT
SELECT * FROM (
  SELECT 1
  EXCEPT
  SELECT 1
)

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions