or (ref($where) eq 'REF' and ref($$where) eq 'ARRAY')
) {
return $self->_literal_to_dq($$where);
- } elsif (!ref($where)) {
+ } elsif (!ref($where) or Scalar::Util::blessed($where)) {
return $self->_value_to_dq($where);
}
die "Can't handle $where";
args => [ ref($v) ? $self->_where_to_dq($v) : $self->_ident_to_dq($v) ]
};
} else {
+ my @args = do {
+ if (ref($v) eq 'HASH' and keys(%$v) == 1 and (keys %$v)[0] =~ /-(.*)/) {
+ my ($inner) = values %$v;
+ +{
+ type => DQ_OPERATOR,
+ operator => { 'SQL.Naive' => uc($1) },
+ args => [
+ (map $self->_where_to_dq($_),
+ (ref($inner) eq 'ARRAY' ? @$inner : $inner))
+ ]
+ };
+ } else {
+ (map $self->_where_to_dq($_), (ref($v) eq 'ARRAY' ? @$v : $v))
+ }
+ };
return +{
type => DQ_OPERATOR,
operator => { 'SQL.Naive' => 'apply' },
args => [
- $self->_ident_to_dq($op),
- (map $self->_where_to_dq($_), (ref($v) eq 'ARRAY' ? @$v : $v))
+ $self->_ident_to_dq($op), @args
],
};
}
},
{
where => { timestamp => { '>=' => { -to_date => '2009-12-21 00:00:00' } } },
- stmt => " WHERE ( timestamp >= TO_DATE ? )",
+ stmt => " WHERE ( timestamp >= TO_DATE(?) )",
bind => ['2009-12-21 00:00:00'],
},
stmt => " WHERE ( (NOT ( c AND (NOT ( (NOT a = ?) AND (NOT b) )) )) ) ",
bind => [ 1 ],
},
+ {
+ where => { foo => { '>=', [] } },
+ stmt => " WHERE 0=1",
+ bind => [ ],
+ },
);
-plan tests => ( @handle_tests * 2 ) + 1;
+plan tests => ( @handle_tests * 2 );
for my $case (@handle_tests) {
local $Data::Dumper::Terse = 1;
fail "Died: $e: Search term:\n" . Dumper $case->{where};
}
}
-
-ok(exception {
- my $sql = SQL::Abstract->new;
- $sql->where({ foo => { '>=' => [] }},);
-});