-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[add] sql-formatter params #6724
base: master
Are you sure you want to change the base?
Conversation
@@ -72,7 +72,7 @@ | |||
"react-grid-layout": "^0.18.2", | |||
"react-resizable": "^1.10.1", | |||
"react-virtualized": "^9.21.2", | |||
"sql-formatter": "git+https://github.com/getredash/sql-formatter.git", | |||
"sql-formatter": "^15.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI the main reason we had a custom sql-formatter
maintained in getredash/sql-formatter is due to the lack of support to the parameters syntax ({{}}
). Previously it would just add line breaks, breaking the query text, with this version it seems to throw an error when a query has them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gabrieldutra
Thanks for the review.
The commit below eliminates the error that occurs when formatting is executed when query parameters are included.
Specifically, we specified {{}} in the paramTypes argument.
I used this link as a reference.
https://github.com/sql-formatter-org/sql-formatter/blob/HEAD/docs/paramTypes.md
@gabrieldutra sqlformatter supports now advanced configuration, so cases, that are covered in a fork can be easily implemented using a latest library version |
@AndrewChubatiuk |
@ko-ya346 thanks for the PR! It'd be pretty nice to remove a manually-maintained dependency. I set the checks to run on this PR, let's see if they pass. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6724 +/- ##
==========================================
- Coverage 63.82% 63.41% -0.41%
==========================================
Files 161 162 +1
Lines 13060 13169 +109
Branches 1803 1819 +16
==========================================
+ Hits 8335 8351 +16
- Misses 4425 4522 +97
+ Partials 300 296 -4 |
@ko-ya346 it looks like the frontend unit tests are failing. Would you mind investigating and seeing if they pass on your local machine? |
looks like this module requires changes in webpack config and its dependencies |
I ran fromtend unit test on my local machine and it failed.
|
package.json
Outdated
@@ -96,7 +96,7 @@ | |||
"@types/prop-types": "^15.7.3", | |||
"@types/react": "^16.14.2", | |||
"@types/react-dom": "^16.9.10", | |||
"@types/sql-formatter": "^2.3.0", | |||
"@types/sql-formatter": "^4.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://www.npmjs.com/package/@types/sql-formatter, it seems sql-formatter now provides its own types? Probably can remove this package, which may be what's failing CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gabrieldutra
Thanks for the review.
You are correct, removing @types/sql-formatter did not affect the behavior.
The frontend tests now pass on my local machine following the recent commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ko-ya346 thanks for this change! I'm excited to give this a try :)
Head branch was pushed to by a user without write access
@guidopetri |
The frontend-e2e-tests are failing, although they passed previously. I cannot determine the cause from the logs, so I will attempt to reproduce the issue for further investigation. |
I'm not sure that the tests failing is related to your changes. Let me investigate first before you spend too much time on a red herring. Do the tests pass for you on your local? |
@guidopetri
|
Thanks @ko-ya346 :) I won't merge this in until our CI on master is passing again, but it does seem like this PR is done. Thank you so much for your work, and hopefully soon we'll merge this in! I'll ping you again if anything else is necessary, but I appreciate all your work. |
Hey @ko-ya346 |
9a6b50a
to
7471d9a
Compare
Tests have passed! |
@justinclift could you please merge it? |
@guidopetri |
What type of PR is this?
Description
This pull request introduces significant improvements to the query editor's formatting functionality in Redash. Previously, the query editor's format feature was limited to default settings. With this update, users can now utilize custom formatting settings defined in a configuration file, allowing for greater flexibility and personalization.
Key Changes:
The versions of sql-formatter and its corresponding TypeScript type definitions have been updated. This upgrade ensures better performance and compatibility with the new formatting features.
Implemented new functionality in queryFormat.js to read formatting settings from an external configuration file. This allows users to define their preferred formatting options, such as indentation style, keyword casing, and other SQL formatting standards.
This enhancement aims to provide a more user-friendly and customizable experience in the query editor, catering to diverse coding styles and preferences.
How is this tested?
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings (if there are UI changes)