PabloRMira / sql_formatter

A Python based SQL formatter
https://pablormira.github.io/sql_formatter/
Apache License 2.0
43 stars 10 forks source link

Variable names ending with `and` get split in `WHERE` statements #161

Closed sambrilleman closed 3 years ago

sambrilleman commented 3 years ago

Describe the bug

Variable names ending with and get split in WHERE statements. E.g. variable name brand becomes br and.

To Reproduce

sql_formatter.core.format_sql("""SELECT brand FROM table WHERE brand = 'my_brand'""")
Out[16]: "SELECT brand\nFROM   table\nWHERE  br\n   and = 'my_brand'"

sql_formatter.core.format_sql("""SELECT hello FROM table WHERE TRUE AND brand = 'my_brand'""")
Out[12]: "SELECT hello\nFROM   table\nWHERE  true\n   and br\n   and = 'my_brand'"

Expected behavior

"SELECT hello\nFROM   table\nWHERE  true\n   and brand = 'my_brand'"

Screenshots

N/A

PabloRMira commented 3 years ago

Many thanks for pointing out and for the very nice bug report! :-)

sambrilleman commented 3 years ago

Wow, thanks for the super fast fix! 😀

PabloRMira commented 3 years ago

You are welcome! :-)

Btw. I've just released the two fixes with version 0.6.2