Skip to content
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

Interaction with sql formatters #39

Open
bglusman opened this issue Nov 4, 2024 · 3 comments
Open

Interaction with sql formatters #39

bglusman opened this issue Nov 4, 2024 · 3 comments

Comments

@bglusman
Copy link
Contributor

bglusman commented Nov 4, 2024

Very early stage of playing with this, but I wanted to adopt consistent .sql formatting in the project, and found https://github.com/akoutmos/sql_fmt which comes with a mix formatter plugin that seems perfect... however, unless I configure it with indent: 0 it looks like it will completely break AyeSQL because it can't tolerate indented comments... wondering easiest way to address this, as it seems like a good pairing otherwise? Putting this up for now for initial thoughts, best guess is it MIGHT only take lexer changes in https://github.com/alexdesousa/ayesql/blob/master/src/ayesql_lexer.xrl to allow for whitespace before a comment? Maybe I'll fork and try and see if I can make that change work locally, but thought I'd put the question here in case any concerns/alternative thoughts...

@bglusman
Copy link
Contributor Author

bglusman commented Nov 4, 2024

Proposed fix, though discovered while making it another seemingly valid option is also just to ensure that the valid queries always end in ; as it won't indent comments unless the fragments below could be part of that query... but... since without this change it breaks otherwise working implementations, think we likely still want this? 🤷‍♂️

@alexdesousa
Copy link
Owner

@bglusman Can you please elaborate? I was checking different comment indentations (both with tabs and spaces) and I still can use the query properly (comments are ignored). Can you give me an example that's breaking the lexer?

I saw in #40, you are allowing white spaces before -- name: and -- docs: keywords. Is the formatter indenting those two?

@bglusman
Copy link
Contributor Author

Yes, if a query doesn't end with ; the formatter will indent comments following that line. I didn't realize this at first and thought I couldn't make the formatter at all compatible with AyeSQL without this change, but, given that its such an easy fix, tolerating it without breaking compilation still seems like an easy win to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants