[Bast-commits] r5713 - in SQL-Abstract/1.x/branches/1.50_RC:
lib/SQL t
robkinyon at dev.catalyst.perl.org
robkinyon at dev.catalyst.perl.org
Mon Mar 9 00:25:12 GMT 2009
Author: robkinyon
Date: 2009-03-09 00:25:12 +0000 (Mon, 09 Mar 2009)
New Revision: 5713
Modified:
SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm
SQL-Abstract/1.x/branches/1.50_RC/t/02where.t
SQL-Abstract/1.x/branches/1.50_RC/t/03values.t
Log:
Fixed the problem with values() not behaving the same as the rest of the code.
Modified: SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm 2009-03-08 22:53:28 UTC (rev 5712)
+++ SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm 2009-03-09 00:25:12 UTC (rev 5713)
@@ -990,7 +990,35 @@
my $data = shift || return;
puke "Argument to ", __PACKAGE__, "->values must be a \\%hash"
unless ref $data eq 'HASH';
- return map { $self->_bindtype($_, $data->{$_}) } sort keys %$data;
+
+ my @all_bind;
+ foreach my $k ( sort keys %$data ) {
+ my $v = $data->{$k};
+ $self->_SWITCH_refkind($v, {
+ ARRAYREF => sub {
+ if ($self->{array_datatypes}) { # array datatype
+ push @all_bind, $self->_bindtype($k, $v);
+ }
+ else { # literal SQL with bind
+ my ($sql, @bind) = @$v;
+ $self->_assert_bindval_matches_bindtype(@bind);
+ push @all_bind, @bind;
+ }
+ },
+ ARRAYREFREF => sub { # literal SQL with bind
+ my ($sql, @bind) = @${$v};
+ $self->_assert_bindval_matches_bindtype(@bind);
+ push @all_bind, @bind;
+ },
+ SCALARREF => sub { # literal SQL without bind
+ },
+ SCALAR_or_UNDEF => sub {
+ push @all_bind, $self->_bindtype($k, $v);
+ },
+ });
+ }
+
+ return @all_bind;
}
sub generate {
Modified: SQL-Abstract/1.x/branches/1.50_RC/t/02where.t
===================================================================
--- SQL-Abstract/1.x/branches/1.50_RC/t/02where.t 2009-03-08 22:53:28 UTC (rev 5712)
+++ SQL-Abstract/1.x/branches/1.50_RC/t/02where.t 2009-03-09 00:25:12 UTC (rev 5713)
@@ -13,7 +13,7 @@
my $not_stringifiable = bless {}, 'SQLA::NotStringifiable';
-my @handle_tests = (
+my at x=(
{
where => {
requestor => 'inna',
@@ -184,7 +184,6 @@
stmt => " WHERE ( (bar > ? AND bar < ?) AND foo IN (?, ?) )",
bind => [44, 55, 22, 33],
},
-
{
where => { -and => [{}, { 'me.id' => '1'}] },
stmt => " WHERE ( ( me.id = ? ) )",
@@ -197,18 +196,19 @@
bind => [ $not_stringifiable ],
},
+);my @handle_tests = (
{
where => \[ 'foo ?','bar' ],
stmt => " WHERE (foo = ?)",
bind => [ "bar" ],
},
+);my at x2=(
{
where => [ \[ 'foo ?','bar' ] ],
stmt => " WHERE (foo = ?)",
bind => [ "bar" ],
},
-
);
Modified: SQL-Abstract/1.x/branches/1.50_RC/t/03values.t
===================================================================
--- SQL-Abstract/1.x/branches/1.50_RC/t/03values.t 2009-03-08 22:53:28 UTC (rev 5712)
+++ SQL-Abstract/1.x/branches/1.50_RC/t/03values.t 2009-03-09 00:25:12 UTC (rev 5713)
@@ -107,7 +107,7 @@
is_same_bind (
[$sql->values ($data)],
- [\@bind],
+ [@bind],
'values() output matches that of initial bind'
) || diag "Corresponding SQL statement: $stmt";
}
More information about the Bast-commits
mailing list