crate / crash

Crash is an interactive CrateDB command line interface (CLI) SQL shell with autocompletion.
Apache License 2.0
48 stars 13 forks source link

Dollar quoted strings not handling semicolon in UPDATE statements #427

Open hlcianfagna opened 9 months ago

hlcianfagna commented 9 months ago
select $$test;test$$;
--> works

create table test(a text);

insert into test(a) values ($$test;test$$);
--> works

update test set a=$$test;test$$;
--> fails (works from the Admin UI)

edit: Bug raised at sqlparse: https://github.com/andialbrecht/sqlparse/issues/763

hlcianfagna commented 9 months ago

Forgot to mention I tested this with crash 0.31.0

hlcianfagna commented 9 months ago

It could be related with https://github.com/andialbrecht/sqlparse/issues/307

amotl commented 9 months ago

Thanks for reporting!

proddata commented 9 months ago

It could be related with andialbrecht/sqlparse#307

I don't think it is.


The issue only seems to happen with =$$

>>> sqlparse.split('''update test set a=$$test;test$$;''');
['update test set a=$$test;', 'test$$;']

>>> sqlparse.split('''update test set a to $$test;test$$;''');
['update test set a to $$test;test$$;']

>>> sqlparse.split('''update test set a = $$test;test$$;''');
['update test set a = $$test;test$$;']

>>> sqlparse.split('''SELECT * FROM t01 WHERE x = $$test;test$$;''');
['SELECT * FROM t01 WHERE x = $$test;test$$;']

>>> sqlparse.split('''SELECT * FROM t01 WHERE x =$$test;test$$;''');
['SELECT * FROM t01 WHERE x =$$test;', 'test$$;']
proddata commented 9 months ago

Bug raised: https://github.com/andialbrecht/sqlparse/issues/763

amotl commented 9 months ago

@proddata submitted a fix already. Thanks a stack!

amotl commented 7 months ago

Hi again.

andialbrecht commented 7 months ago

A new version of sqlparse will be released in May when LTS support for Django 3.2 has reached its EOL.

amotl commented 6 months ago

Hi again. sqlparse 0.5 has been released, and the most recent release of crash, version 0.31.5, permits to use it. Thank you so much for your contributions and support!

pip install --upgrade sqlparse