Skip Menu |

This queue is for tickets about the SQL-Abstract CPAN distribution.

Report information
The Basics
Id: 99503
Status: resolved
Priority: 0/
Queue: SQL-Abstract

People
Owner: Nobody in particular
Requestors: KARASIK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.81



Subject: _open_outer_paren uses too aggressive regex
removes too many parentheses when the statement is in format f.x. "(SELECT a) UNION (SELECT b)" SQL/Abstract.pm:1052 $sql = $1 while $sql =~ /^ \s* \( (.*) \) \s* $/xs;
On Wed Oct 15 09:46:51 2014, KARASIK wrote: Show quoted text
> removes too many parentheses when the statement is in format f.x. > "(SELECT a) UNION (SELECT b)" > > SQL/Abstract.pm:1052 $sql = $1 while $sql =~ /^ \s* \( (.*) \) \s* $/xs;
Indeed, that's a shortsighted fuckup on my end. Please add the *entire* ->where() call that is failing to render properly, so we have a stable starting point to work from.
Here's a (bad) DBIx::Class example I have: my $c = $schema->resultset('Table')->search({id => 2}); print $c->search({'id' => {'-in' => \"(select 1) union (select 2)"}}); which fails with DBIx::Class::ResultSet::search(): DBI Exception: DBD::Pg::st execute failed: ERROR: syntax error at or near "union" LINE 1: ...t"."construct" "me" WHERE ( ( "id" IN ( select 1) union (sel... ^ [for Statement "SELECT "me"."id" FROM "table" "me" WHERE ( ( "id" IN ( select 1) union (select 2 ) AND "id" = ? ) )" with ParamValues: 1='2'] at a.pl line 22 I don't have the corresponding SQL::Abstract code, sorry. Dmitry
On Wed Oct 15 11:11:46 2014, KARASIK wrote: Show quoted text
> Here's a (bad) DBIx::Class example I have: > > my $c = $schema->resultset('Table')->search({id => 2}); > print $c->search({'id' => {'-in' => \"(select 1) union (select 2)"}});
Sorry for taking a while to get back to this. One of the reasons for the delay was that it took me a while to sensibly reproduce. It turns out that the above (surprisingly) is pg-specific syntax. That is: SELECT * FROM ( ( SELECT(1) ) UNION ( SELECT(2) ) ) foo is *NOT* valid on SQLite (though valid on Pg) While SELECT * FROM ( SELECT(1) UNION SELECT(2) ) foo is valid on both SQLite and Pg. Nevertheless the issue is real and it has been fixed in https://github.com/dbsrgits/dbix-class/commit/4f52479b6 Thanks for the report!
On Sat Oct 25 13:36:02 2014, RIBASUSHI wrote: Show quoted text
Don't know what happened there - the correct link is https://github.com/dbsrgits/sql-abstract/commit/a5f91febe5