-
Notifications
You must be signed in to change notification settings - Fork 422
[FORMATTING] Inconsistent formatting for queries with $$
#682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The formatting works as designed. It's just that the contents of $$-quoted string aren't indented, a feature requested in #680 which is not implemented. So in that sense this bug report is a duplicate of that feature request. |
If there is a |
That would go against the core formatting logic, which is that the formatter discards all non-significant whitespace. The whitespace inside strings is assumed to be significant and therefore not modified. For example one could write a python script inside $$-quoted string. Whitespace in Python is significant and modifying it would lead to broken code. |
Understood, then maybe this is something for |
Since this seems to be a dead end for any kind of implementation in |
As I've learned in Sec-ant/prettier-plugin-embed#45 (comment), there is actually a small bug in
sql-formatter
with queries including$$
:The lines are not consistently indented - the leading space is stripped from the first line, but the others are untouched, by design.
Input data
Which SQL and options did you provide as input?
Note the leading spaces on the first line:
Expected Output
Alternative (no indentation formatting, including first line):
Actual Output
Leading spaces on the first line are removed, but indentation on the following lines are untouched, by design
Usage
prettier-plugin-sql
andprettier-plugin-embed
14.1.0-beta.2
This appears to be causing the unstable formatting with
prettier-plugin-embed
outlined in the following issue:sql-formatter
dialect
option Sec-ant/prettier-plugin-embed#45Kapture.2023-12-03.at.19.08.00.mp4
Suggested Solution
Either of the following would resolve this issue:
$$
, format the rest of the string with indentation matching the delta from the first line (in this example,-12
) à ladedent
$$
Related
The text was updated successfully, but these errors were encountered: