sqlparse
sqlparse copied to clipboard
comparison including SQL keywords
consider parsing a simple SET statement:
sqlparse.parse("SET fsync=true;")[0].tokens
the result is:
[<Keyword 'SET' at 0x7F40E138E348>, <Whitespace ' ' at 0x7F40E138E3A8>, <Whitespace ' ' at 0x7F40E138E408>,
<Identifier 'fsync' at 0x7F40E13E65E8>, <Comparison '=' at 0x7F40E138E4C8>, <Keyword 'true' at 0x7F40E138E528>,
<Punctuation ';' at 0x7F40E138E588>]
the comparison clause is not parsed correctly comparing with the belowing parsing result of statement without the SQL keyword false
:
sqlparse.parse("SET fsync=0;")[0].tokens
[<Keyword 'SET' at 0x7F40E138E948>, <Whitespace ' ' at 0x7F40E138E9A8>, <Whitespace ' ' at 0x7F40E138EA08>,
<Comparison 'fsync=0' at 0x7F40E13E6840>, <Punctuation ';' at 0x7F40E138EB88>]