sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

Keywords are uppercased even when they are used as identifiers

Open alec-heif opened this issue 3 years ago • 1 comments

It seems that sqlparse.format considers words like date and segment as SQL identifiers, and so when these words are used as identifiers with keyword_case=True, sqlparse will automatically uppercase them.

It would be ideal if keywords would be only treated as keywords when they are used as keywords instead of naively uppercasing segment anywhere it is used. This can cause confusion to users when their column names are uppercased unexpectedly.

alec-heif avatar Mar 05 '21 16:03 alec-heif

fwiw this is affecting us too. For example:

SELECT 1 AS count;

turns into:

SELECT 1 AS COUNT;

and

CREATE TABLE foo (count INT);

turns into:

CREATE TABLE foo (COUNT INT);

kzidane avatar Mar 25 '21 12:03 kzidane