inline_sql_syntax icon indicating copy to clipboard operation
inline_sql_syntax copied to clipboard

Support Python f-string

Open Jeromearsene opened this issue 2 years ago • 5 comments

It's impossible to parse Python f-strings for the moment:

Capture d’écran 2022-06-23 à 09 42 43

Capture d’écran 2022-06-23 à 09 43 15

It would be very practical to add this possibility 🙏

Jeromearsene avatar Jun 23 '22 07:06 Jeromearsene

Added syntax highlighting for multi-line f-strings in 2.14

barklan avatar Jun 23 '22 12:06 barklan

Sorry, but I don't understand how it works. I tried with your Python example but got this result: Capture d’écran 2022-06-23 à 15 41 15

So, I conclude that doesn't work.

You explain here never to do that. Ok, this is not a good practice. But should we understand that it is impossible with your lib ?

Thanks for explanations

Jeromearsene avatar Jun 23 '22 13:06 Jeromearsene

But should we understand that it is impossible with your lib ?

No, it's not my place to "punish" people for something that might be unsafe. And there is no indication of unsanitized input here. The last two strings in your screenshot work for me. Not sure yet why they don't work for you.

Screenshot_20220623_184006

I also prematurely closed it without adding support for single-line f-strings) Will add later.

The only string that does not work by design (so far) is this one:

multiline_without_marker = f"""
    SELECT * FROM {table_name};
"""

I've open separate issue for queries like this one: #78. Thanks for your input.

barklan avatar Jun 23 '22 16:06 barklan

With your last version it's good ! Capture d’écran 2022-06-24 à 10 11 08

Before update: Capture d’écran 2022-06-24 à 10 08 07

Jeromearsene avatar Jun 24 '22 08:06 Jeromearsene

I also prematurely closed it without adding support for single-line f-strings) Will add later.

As far as I can tell, single-line f-strings are still not supported :(

torzsmokus avatar Aug 06 '24 11:08 torzsmokus