pgjones / flake8-sql

Flake8 plugin that checks SQL code against opinionated style rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL queries inside f-strings (Python 3.6+) are not being checked

fgimian opened this issue · comments

Hey there, another little issue I discovered is that SQL inside f-strings are not being checked:

e.g.

Lines 61 - 65:

        for item_id, title, uuid, flags in self.conn.execute(f'''
            SELECT {table}.item_id, {table}.title, items.uuid, items.flags
            FROM {table}
            JOIN items ON items.rowid = {table}.item_id
        '''):

These show no errors, but if I remove the f prior to the string starting, I see:

./elite/libraries/launchpad_builder.py:65:0: Q447 root_keywords SELECT and FROM are not right aligned
./elite/libraries/launchpad_builder.py:65:0: Q449 token { should be aligned to the right of the river
./elite/libraries/launchpad_builder.py:65:0: Q449 token table should be aligned to the right of the river
./elite/libraries/launchpad_builder.py:65:0: Q447 root_keywords SELECT and JOIN are not right aligned
./elite/libraries/launchpad_builder.py:65:0: Q449 token items should be aligned to the right of the river

Kindest Regards
Fotis

I think I've fixed this in 6da30ca, could you try it and see if it fixes your issue(s)?

Thanks so much @pgjones, I'm so sorry for the delay, this week has been a bit nuts. I'll try to check this out on the upcoming weekend and let you know if it's all good 😄

Cheers
Fotis

I can confirm that the fix implemented indeed repairs this issue, thank you so much! 😄

Cheers
Fotis

Thanks, I've released 0.3.0