* Marc Mims [EMAIL PROTECTED] [070928 00:45]:
=== lib/DBIx/Class/Storage/DBI.pm
==
--- lib/DBIx/Class/Storage/DBI.pm (revision 1335)
+++ lib/DBIx/Class/Storage/DBI.pm (local)
@@ -913,7 +913,7 @@
my ($self, $op, $extra_bind, $ident, $args) = @_;
my ($sql, @bind) = $self-sql_maker-$op($ident, @$args);
- unshift(@bind,
+ push(@bind,
map { ref $_ eq 'ARRAY' ? $_ : [ '!!dummy', $_ ] } @$extra_bind)
if $extra_bind;
The attached test fails without the patch, succeeds with it, and all
other tests in 0.08/trunk pass with it.
Can it be this simple? Surely there was some reason for unshift instead
of push, but I didn't discover it.
No. It's not that simple. An updated test is attached. The simple
cases pass with the patch applied. But the complex tests, based on the
Cookbook Arbitrary SQL technique fail.
http://search.cpan.org/~ash/DBIx-Class-0.08007/lib/DBIx/Class/Manual/Cookbook.pod#Arbitrary_SQL_through_a_custom_ResultSource
I'm not sure how to tackle this problem in a way that will satisfy all
the tests...yet.
-Marc
use strict;
use warnings;
use Test::More;
use lib qw(t/lib);
use DBICTest;
my $schema = DBICTest-init_schema;
BEGIN {
eval use DBD::SQLite;
plan $@
? ( skip_all = 'needs DBD::SQLite for testing' )
: ( tests = 7 );
}
### $schema-storage-debug(1);
my $where_bind = {
where = \'name like ?',
bind = [ 'Cat%' ],
};
# First, the simple cases...
my $rs = $schema-resultset('Artist')-search(
{ artistid = 1 },
$where_bind,
);
is ( $rs-count, 1, 'where/bind combined' );
$rs= $schema-resultset('Artist')-search({}, $where_bind)
-search({ artistid = 1});
is ( $rs-count, 1, 'where/bind first' );
$rs = $schema-resultset('Artist')-search({ artistid = 1})
-search({}, $where_bind);
is ( $rs-count, 1, 'where/bind last' );
# More complex cases, based primarily on the Cookbook
# Arbitrary SQL through a custom ResultSource technique,
# which seems to be the only place the bind attribute is
# documented. Breaking this technique probably breaks existing
# application code.
my $source = DBICTest::Artist-result_source_instance;
my $new_source = $source-new($source);
$new_source-source_name('Complex');
$new_source-name(\'');
( select a.*, cd.cdid as cdid, cd.title as title, cd.year as year
from artist a
join cd on cd.artist=a.artistid
where cd.year=?)
$schema-register_source('Complex' = $new_source);
$rs = $schema-resultset('Complex')-search({}, { bind = [ 1999 ] });
is ( $rs-count, 1, 'cookbook arbitrary sql example' );
$rs = $schema-resultset('Complex')-search({ 'artistid' = 1 }, { bind = [ 1999 ] });
is ( $rs-count, 1, '...coobook + search condition' );
$rs = $schema-resultset('Complex')-search({}, { bind = [ 1999 ] })
-search({ 'artistid' = 1 });
is ( $rs-count, 1, '...cookbook (bind first) + chained search' );
$rs = $schema-resultset('Complex')-search({}, { bind = [ 1999 ] })
-search({ 'artistid' = 1 }, { where = \'title like ?', bind = [ 'Spoon%' ] });
is ( $rs-count, 1, '...cookbook + chained search with extra bind' );
___
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]