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

SQL coloration for Repo.query! #67

Open
saveman71 opened this issue Jan 4, 2024 · 5 comments
Open

SQL coloration for Repo.query! #67

saveman71 opened this issue Jan 4, 2024 · 5 comments

Comments

@saveman71
Copy link

saveman71 commented Jan 4, 2024

Hello! thanks for the great package.

i'm trying to add Repo.query! as a valid way to start an SQL fragment.

By just adding it to the list like so:

  ## SQL

  sql_or_fragment:
    - match: (?>(fragment)|(sql)|(Repo\.query!))(\()

It kinda works, but it looses the function coloration, i.e. becomes white:

Before:
image

After:
image

It's miles better, but what am I missing? Adding only query! doesn't work at all.

@saveman71
Copy link
Author

There's also this form

result = Ecto.Adapters.SQL.query!(MyRepo, "SELECT * FROM users", [])

But harder to deal with since the query is at the second position.

@azizk
Copy link
Collaborator

azizk commented Jan 4, 2024

You're welcome! Thanks for the suggestion! I managed to implement it. Can you check out the v3.3.0 branch (PR #68)?

@saveman71
Copy link
Author

saveman71 commented Jan 5, 2024

Works almost like a charm! Looking at the PR it seems like it's trying to look at popping arguments for this case:

Ecto.Adapters.SQL.query!(MyRepo, "SELECT * FROM users", [])

?

This doesn't seem to work.

For what it's worth, we also use the aliased version

SQL.query!(MyRepo, "SELECT * FROM users", [])

But Repo.query! works perfectly:

image

@saveman71
Copy link
Author

(note, i'm only pointing it out because I thought your change was trying to handle that case, if that's not the case no worries, this must be a pain to handle I guess)

@azizk
Copy link
Collaborator

azizk commented Jun 16, 2024

I think I solved this now. 👍 Better late than never... 😅

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