Skip to content

Buggy example #208

@kodonnell

Description

@kodonnell

This does not work for me with version 0.1.18:

>>> import sqlparse
>>> sql = """  create procedure db.sp()
...   begin
...   
...   create table t1 select a from t where abc;
...     
...   create table t2 select
...     avg(a) as a,
...   std(a) as a,
...     avg(a) as a,
...   std(a) as a,
...     avg(a) as a,
...   std(a) as a,
...     avg(a) as a,
...   std(a) as a,
...     avg(a) as a,
...   std(a) as a,
...     avg(a) as a,
...   std(a) as a
...   from t ; 
...   
...   create table t3
...   select
...     a,  
...     0
...   from t;
...   
...   end; 
... """
>>> sqlparse.parse(sql)

This fixes it:

>>> sqlparse.parse(sql.replace('end; \n', 'end'))

and so does messing round with the sql statements (e.g. deleting one of the columns in t2 or t3). I've had a quick look, and while I don't know the root of the cause, it might pay to add an if tokens: ... into group_tokens in sql.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions