2022-10-30

Sublime Text 4 sql highlight inside a string [closed]

Currently, if I have sql commands inside a python string, Sublime Text highlights it. However if it's an "f string", it does not recognize the sql inside. Is there any way to make it work the same way as a regular string?

This reproduces on builtin Python syntax, which has support for SQL strings highlighting. SQL is detected by non-formatted string starting with uppercase SQL common query identifier (SELECT, DELETE, UPDATE, INSERT, CREATE TABLE, etc.). However, by design this is not triggered for format strings (with f or F prefix) and raw strings with R prefix (the latter is very weird, given that lowercase r is widely used for regexes, while uppercase - for raw strings in any other context). Is there any way to enable embedded SQL highlight for format strings? Maintainer's position is quite understandable (do not format SQL - use placeholders to be formatted by dedicated library), but it's not always the case: sometimes I'm building queries from parts using f-strings, where none of the parts are user input or variables, but just a fixed string for reusability & readability purposes.

example of sql highlight



No comments:

Post a Comment