-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Copied from original sql-formatter issue: sql-formatter-org/sql-formatter#684
Describe the Feature
New default behavior in prettier-plugin-sql-cst to remove unnecessary parentheses in SQL (maybe with a way to disable):
-- Before
SELECT
sessions.id
FROM
sessions
WHERE
(
(sessions.token = 'abc123')
AND (sessions.user_id = 17)
AND (sessions.expiry_timestamp > now())
);
-- After
SELECT
sessions.id
FROM
sessions
WHERE
sessions.token = 'abc123'
AND sessions.user_id = 17
AND sessions.expiry_timestamp > now();Why do you want this feature?
Removing extra unnecessary parentheses can make code simpler and less nested
Prior art
Prettier does this:
Other projects also have had similar requests / implementation:
- EF core should probably clear meaningless parentheses in generated sql queries dotnet/efcore#28615
- Remove unneeded parentheses in SQL queries dotnet/efcore#26767
- Full management of SQL operator precedence/associativity dotnet/efcore#30371
Keywords for Search
Operator precedence, operators, parenthesis
philiptzou
Metadata
Metadata
Assignees
Labels
No labels
