crash icon indicating copy to clipboard operation
crash copied to clipboard

Dollar quoted strings not handling semicolon in UPDATE statements

Open hlcianfagna opened this issue 1 year ago • 9 comments

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 avatar Feb 01 '24 11:02 hlcianfagna

Forgot to mention I tested this with crash 0.31.0

hlcianfagna avatar Feb 01 '24 12:02 hlcianfagna

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

hlcianfagna avatar Feb 01 '24 13:02 hlcianfagna

Thanks for reporting!

amotl avatar Feb 01 '24 14:02 amotl

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 avatar Feb 03 '24 08:02 proddata

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

proddata avatar Feb 05 '24 06:02 proddata

@proddata submitted a fix already. Thanks a stack!

  • https://github.com/andialbrecht/sqlparse/pull/764

amotl avatar Feb 07 '24 16:02 amotl

Hi again.

  • https://github.com/andialbrecht/sqlparse/pull/764 has been merged. Thank you so much, @proddata and @andialbrecht. 💯
  • After a new release of sqlparse has been published on PyPI, this needs to be concluded with a corresponding update and (just a little) test case over here.

amotl avatar Mar 27 '24 19:03 amotl

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

andialbrecht avatar Mar 27 '24 21:03 andialbrecht

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
  • https://github.com/crate/crash/pull/437
  • https://github.com/crate/crash/releases/tag/0.31.5

amotl avatar Apr 24 '24 18:04 amotl