Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 67913
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: frogomatic [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.08127
Fixed in: (no value)



Subject: select sum(foo) with 'as' generates invalid SQL
Download (untitled) / with headers
text/plain 1.3k
Hopefully this is complete enough. We're using SQL::Abstract version 1.72, Perl 5.10.0, MySQL. How to replicate: Create an 'entries' table with: CREATE TABLE entries (id int not null primary key auto_increment, debit int, credit int); No need to populate it. Write a trivial Test/Schema.pm and Test/Schema/Result/Entries.pm (included in attached tarball). DBIC_TRACE=1 ; export DBIC_TRACE When I do this: my @x = $schema->resultset('Entries')->search({}, { select => 'sum(debit) - sum(credit)', as => 'assets' } ); what it actually tries is: SELECT me.sum(debit) - sum(credit) FROM entries me; instead of SELECT sum(me.debit) - sum(me.credit) FROM entries me; and an exception is thrown (FUNCTION me.sum does not exist...). The same problem happens if you just use select => 'sum(debit)'. It seems to be putting the "me." in the wrong place. This worked just fine in the last version of DBIC we were using. Unfortunately I don't know what that was; we had to rebuild our EC2 instance after the last outage and lost that information. It does work in SQL::Abstract 1.60 and DBIC version 0.08112. I'm largely unfamiliar with the guts of DBIC. If necessary I can track this down myself I can and issue a patch, but if this has already been reported and fixed, I'd like to save myself the time. Plus I'm sure someone more familiar with the code can do it more quickly and elegantly. Thank you!
Subject: DBICbug.tar.gz
Download DBICbug.tar.gz
application/gzip 615b

Message body not shown because it is not plain text.

From: frogomatic [...] gmail.com
Just tested this with DBIC 0.08191. Still happening.
Download (untitled) / with headers
text/plain 211b
To tell DBIC that you pass literal sql you need to do this as reference: my @x = $schema->resultset('Entries')->search(undef, { select => \'sum(debit) - sum(credit)', as => 'assets', });


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.