X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FAbstract%2FCompat.pm;fp=lib%2FSQL%2FAbstract%2FCompat.pm;h=0850164089a0ce59e7b40bed657c6d1ad894a8e8;hb=b6c45ef3d4431be02339c183912fda2016f92913;hp=5045664435cde8a878649bbe841c9238e9d5d86a;hpb=946503a6fcccde2029657cb6b1a4c2b976a6ff50;p=dbsrgits%2FSQL-Abstract-2.0-ish.git diff --git a/lib/SQL/Abstract/Compat.pm b/lib/SQL/Abstract/Compat.pm index 5045664..0850164 100644 --- a/lib/SQL/Abstract/Compat.pm +++ b/lib/SQL/Abstract/Compat.pm @@ -12,7 +12,6 @@ class SQL::Abstract::Compat { use Carp qw/croak/; class_type 'SQL::Abstract'; - clean; has logic => ( is => 'rw', @@ -107,6 +106,9 @@ class SQL::Abstract::Compat { push @values, { -type => 'value', value => $fields->{$_} }; } + $ast->{where} = $self->recurse_where($where) + if defined $where; + return $ast; } @@ -177,14 +179,14 @@ class SQL::Abstract::Compat { }; } - method recurse_where(WhereType $ast, LogicEnum $logic?) returns (AST) { + method recurse_where(WhereType $ast, LogicEnum $logic?) { return $self->recurse_where_hash($logic || 'AND', $ast) if is_HashRef($ast); return $self->recurse_where_array($logic || 'OR', $ast) if is_ArrayRef($ast); croak "Unknown where clause type " . dump($ast); } # Deals with where({ .... }) case - method recurse_where_hash(LogicEnum $logic, HashRef $ast) returns (AST) { + method recurse_where_hash(LogicEnum $logic, HashRef $ast) { my @args; my $ret = { -type => 'expr', @@ -215,7 +217,7 @@ class SQL::Abstract::Compat { } # Deals with where([ .... ]) case - method recurse_where_array(LogicEnum $logic, ArrayRef $ast) returns (AST) { + method recurse_where_array(LogicEnum $logic, ArrayRef $ast) { my @args; my $ret = { -type => 'expr', @@ -248,7 +250,7 @@ class SQL::Abstract::Compat { } # { field => { .... } } case - method field_hash(Str $key, HashRef $value) returns (AST) { + method field_hash(Str $key, HashRef $value) { my ($op, @rest) = keys %$value; confess "Don't know how to handle " . dump($value) . " (too many keys)" @@ -313,7 +315,7 @@ class SQL::Abstract::Compat { }; } - method field(Str $key, $value) returns (AST) { + method field(Str $key, $value) { if (is_HashRef($value)) { return $self->field_hash($key, $value); @@ -334,7 +336,7 @@ class SQL::Abstract::Compat { return $ret; } - method value($value) returns (AST) { + method value($value) { return $self->apply_convert( { -type => 'value', value => $value }) if is_Str($value);