sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

comparison including SQL keywords

Open IterableTrucks opened this issue 3 years ago • 0 comments

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>]

IterableTrucks avatar Jun 17 '21 11:06 IterableTrucks