elixir-sublime-syntax icon indicating copy to clipboard operation
elixir-sublime-syntax copied to clipboard

SQL coloration for `Repo.query!`

Open saveman71 opened this issue 1 year ago • 5 comments

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 avatar Jan 04 '24 11:01 saveman71

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.

saveman71 avatar Jan 04 '24 11:01 saveman71

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

azizk avatar Jan 04 '24 22:01 azizk

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 avatar Jan 05 '24 09:01 saveman71

(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)

saveman71 avatar Jan 05 '24 09:01 saveman71

I think I solved this now. :+1: Better late than never... :sweat_smile:

azizk avatar Jun 16 '24 23:06 azizk