bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

Auto adding "LIMIT" to quick_select lets fail queries for DBD::Oracle #39

Open sneils opened 11 years ago

sneils commented 11 years ago

DBD::Oracle or rather Oracle in common doesn't have a "LIMIT" key word, so database->quick_select produces invalid queries!

Dancer::Plugin::Database::Handle

306: } elsif ($type eq 'SELECT' && !wantarray) {
307:        # We're only returning one row in scalar context, so don't ask for any
308:        # more than that
309:        $sql .= " LIMIT 1";
310: }

So the following

my $row = database->quick_select('mytable', { id => params->{id} });

Produces

(DBD ERROR: error possibly near <_> indicator at char 46 in 'SELECT * FROM "mytable" WHERE "id"=:p1 <_>LIMIT 1') [for Statement "SELECT * FROM "mytable" WHERE "id"=? LIMIT 1"] at /usr/lib/perl5/site_perl/5.10.0/Dancer/Plugin/Database/Handle.pm line 336