You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a problem with prettier-plugin-sql (using sql-formatter) indentation with interpolation in a condition of a WHERE condition line:
Expected:
sql` SELECT * FROM longer_table_name_with_many_characters WHERE longer_table_name_with_many_characters.id IN ${sql(longerTableNameWithManyCharactersIds,)}`
Actual:
(the 2 lines after sql( are missing 1 indent level)
sql` SELECT * FROM longer_table_name_with_many_characters WHERE longer_table_name_with_many_characters.id IN ${sql(longerTableNameWithManyCharactersIds,)}`
This problem also extends to any other indented areas, eg. this FROM clause:
The sql-formatter demo seems to indent correctly, with a parenthesized expression spanning multiple lines (no ability to interpolate here, since it's only SQL, no JS template strings):
Wrapping the interpolation in parentheses works around the problem:
sql` SELECT * FROM longer_table_name_with_many_characters WHERE longer_table_name_with_many_characters.id IN (${sql(longerTableNameWithManyCharactersIds)} )`
But this workaround fails with a similar problem if the JS expression is too long and Prettier wraps it:
sql` SELECT * FROM longer_table_name_with_many_characters WHERE longer_table_name_with_many_characters.id IN (${sql(evenLongerTableNameWithManyCharactersKeepsGoingEvenLongerAndLongerAndLongerIds,)} )`;
karlhorky
changed the title
Indentation of interpolated expression missing an indent level
SQL: Indentation of interpolated expression missing an indent level
Apr 10, 2024
Hi @Sec-ant 👋 Hope you're good!
I encountered a problem with
prettier-plugin-sql
(usingsql-formatter
) indentation with interpolation in a condition of aWHERE
condition line:Expected:
Actual:
(the 2 lines after
sql(
are missing 1 indent level)This problem also extends to any other indented areas, eg. this
FROM
clause:The
sql-formatter
demo seems to indent correctly, with a parenthesized expression spanning multiple lines (no ability to interpolate here, since it's only SQL, no JS template strings):The text was updated successfully, but these errors were encountered: