From: Matt S Trout Date: Mon, 25 Jul 2011 15:04:45 +0000 (+0000) Subject: apply type op and NULL handling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=829906e07a7e208fcc2ef2f3e625f649d9a298e8;p=dbsrgits%2FData-Query.git apply type op and NULL handling --- diff --git a/lib/Data/Query/Renderer/SQL/Naive.pm b/lib/Data/Query/Renderer/SQL/Naive.pm index bb81339..c20e610 100644 --- a/lib/Data/Query/Renderer/SQL/Naive.pm +++ b/lib/Data/Query/Renderer/SQL/Naive.pm @@ -28,7 +28,8 @@ sub _default_simple_ops { (map +($_ => 'unop_reverse'), ('IS NULL', 'IS NOT NULL')), (map +($_ => 'flatten'), qw(AND OR) ), (map +($_ => 'in'), ('IN', 'NOT IN')), - (map +($_ => 'between'), ('BETWEEN', 'NOT BETWEEN')) + (map +($_ => 'between'), ('BETWEEN', 'NOT BETWEEN')), + (apply => 'apply'), } } @@ -100,7 +101,9 @@ sub _render_identifier { } sub _render_value { - [ '?', $_[1] ]; + defined($_[1]->{value}) + ? [ '?', $_[1] ] + : [ 'NULL' ]; } sub _operator_type { 'SQL.Naive' } @@ -198,6 +201,19 @@ sub _handle_op_type_between { [ $lhs, $op_name, $rhs1, 'AND', $rhs2 ]; } +sub _handle_op_type_apply { + my ($self, $op_name, $dq) = @_; + my ($func, @args) = @{$dq->{args}}; + die "Function name must be identifier" + unless $func->{type} eq DQ_IDENTIFIER; + my $ident = $self->_render($func)->[0]; + [ + "$ident(", + (map $self->_render($_), @args), + ')' + ] +} + sub _convert_op { my ($self, $dq) = @_; if (my $perl_op = $dq->{'operator'}->{'Perl'}) {