Select with WHERE
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract / AST / v1.pm
index a8860b5..d0f4522 100644 (file)
@@ -54,14 +54,15 @@ class SQL::Abstract::AST::v1 extends SQL::Abstract {
     push @output, FROM => $self->dispatch($ast->{tablespec})
       if exists $ast->{tablespec};
 
-    for (qw//) {
+    for (qw/where having group_by/) {
       if (exists $ast->{$_}) {
         my $sub_ast = $ast->{$_};
-        $sub_ast->{-type} = "$_" if is_HashRef($sub_ast);
-        confess "$_ option is not an AST"
+
+        confess "$_ option is not an AST: " . dump($sub_ast)
           unless is_AST($sub_ast);
 
-        push @output, $self->dispatch($sub_ast);
+        my $meth = "__$_";
+        push @output, $self->$meth($sub_ast);
       }
     }
 
@@ -153,6 +154,11 @@ class SQL::Abstract::AST::v1 extends SQL::Abstract {
     return "?";
   }
 
+  # Not dispatchable to.
+  method __where(HashAST $ast) {
+    return "WHERE " . $self->_expr($ast);
+  }
+
   # Perhaps badly named. handles 'and' and 'or' clauses
   method _recurse_where(HashAST $ast) {