Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed the tests.

Thanks to ribasushi on IRC for pointing me to the $k variable.
  • Loading branch information...
commit 1e008bba83e304e973f837cddb837664e1142b69 1 parent 88a79ec
@shlomif authored
Showing with 10 additions and 6 deletions.
  1. +8 −2 lib/SQL/Abstract.pm
  2. +2 −4 t/01generate.t
View
10 lib/SQL/Abstract.pm
@@ -935,12 +935,18 @@ sub _where_field_BETWEEN {
sub _where_field_FUNC {
my ($self, $k, $op, $vals) = @_;
- return $self->_where_op_FUNC($k,$vals);
+ return $self->_where_generic_FUNC($k,$vals);
}
sub _where_op_FUNC {
my ($self, $k, $vals) = @_;
+ return $self->_where_generic_FUNC('', $vals);
+}
+
+sub _where_generic_FUNC {
+ my ($self, $k, $vals) = @_;
+
my $label = $self->_convert($self->_quote($k));
my $placeholder = $self->_convert('?');
my $error = "special op 'func' accepts an arrayref with more than one value.";
@@ -1002,7 +1008,7 @@ sub _where_op_FUNC {
},
});
- my $sql = "( $clause )";
+ my $sql = $k ? "( $label = $clause )" : "( $clause )";
return ($sql, @bind)
}
View
6 t/01generate.t
@@ -539,7 +539,6 @@ my @tests =
stmt_q => 'SELECT * FROM `jeff` WHERE (substr(?, ?, ?))',
bind => [1010,5,6],
},
-
{
func => 'select',
args => ['jeff', '*',
@@ -551,13 +550,12 @@ my @tests =
},
}
],
- stmt => 'SELECT * FROM jeff WHERE a = foo(max(?), (SELECT crate FROM baz))',
- stmt_q => 'SELECT * FROM `jeff` WHERE `a` = foo(max(?), (SELECT crate FROM baz))',
+ stmt => 'SELECT * FROM jeff WHERE (a = foo((max(?)), (SELECT crate FROM baz)))',
+ stmt_q => 'SELECT * FROM `jeff` WHERE (`a` = foo((max(?)), (SELECT crate FROM baz)))',
bind => ['bar'],
},
);
-
plan tests => scalar(grep { !$_->{warning_like} } @tests) * 2
+ scalar(grep { $_->{warning_like} } @tests) * 4;
Please sign in to comment.
Something went wrong with that request. Please try again.