sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

trouble parsing datetime keyword

Open abe-winter opened this issue 5 years ago • 0 comments

Expected behavior

Column name + datetime type are separate tokens

Actual behavior

For datetime specifically, the parser doesn't split column name + type into separate tokens. (See example below where timestamp and int work correctly).

I'm willing to help solve this if it's truly a bug -- let me know if you want me to submit a PR.

Versions

I tested on 0.3.0 and 0.3.1, happens on both

Example

>>> import sqlparse
>>> sqlparse.__version__
'0.3.1'
# wrong: datetime
>>> list(map(str, sqlparse.parse('create table t (t datetime)')[0][-1][-1]))
['(', 't datetime', ')']
# ok: timestamp
>>> list(map(str, sqlparse.parse('create table t (t timestamp)')[0][-1][-1]))
['(', 't', ' ', 'timestamp', ')']
# ok: int
>>> list(map(str, sqlparse.parse('create table t (t int)')[0][-1][-1]))
['(', 't', ' ', 'int', ')']

abe-winter avatar May 16 '20 04:05 abe-winter