Update clases test+functionality
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract.pm
index 95178a4..26b3ce1 100644 (file)
@@ -8,7 +8,7 @@ class SQL::Abstract {
   use Moose::Util::TypeConstraints;
   use MooseX::Types::Moose qw/ArrayRef Str Int HashRef CodeRef/;
   use MooseX::AttributeHelpers;
-  use SQL::Abstract::Types qw/NameSeparator QuoteChars AST HashAST ArrayAST/;
+  use SQL::Abstract::Types qw/NameSeparator QuoteChars AST/;
   use Devel::PartialDump qw/dump/;
 
   clean;
@@ -24,6 +24,12 @@ class SQL::Abstract {
   );
 
   our %BINOP_MAP = (
+
+    '+' => '+',
+    '-' => '-',
+    '/' => '/',
+    '*' => '*',
+
     '>' => '>',
     '>=' => '>=',
     '<' => '<',
@@ -31,8 +37,8 @@ class SQL::Abstract {
     '==' => '=',
     '!=' => '!=',
     # LIKE is always "field LIKE <value>"
-    '-like' => 'LIKE',
-    '-not_like' => 'NOT LIKE',
+    'like' => 'LIKE',
+    'not_like' => 'NOT LIKE',
   );
 
   has expr_dispatch_table => (
@@ -75,7 +81,7 @@ class SQL::Abstract {
     required => 1
   );
 
-  has name_separator => ( 
+  has ident_separator => ( 
     is => 'rw', 
     isa => NameSeparator,
     default => '.',
@@ -110,6 +116,7 @@ class SQL::Abstract {
   );
 
   # TODO: once MXMS supports %args, use that here
+  # TODO: improve this so you can pass other args
   method create(ClassName $class: Int $ver) {
     croak "AST version $ver is greater than supported version of $AST_VERSION"
       if $ver > $AST_VERSION;
@@ -121,7 +128,7 @@ class SQL::Abstract {
   }
 
   # Main entry point
-  method generate(ClassName $class: HashAST $ast) {
+  method generate(ClassName $class: AST $ast) {
     my $ver = $ast->{-ast_version};
     croak "SQL::Abstract AST version not specified"
       unless defined $ver;
@@ -138,14 +145,7 @@ class SQL::Abstract {
 
   method dispatch (AST $ast) {
 
-
-    # I want multi methods!
-    my $tag;
-    if (is_ArrayAST($ast)) {
-      confess "FIX: " . dump($ast); 
-    } else {
-      $tag = "_" . $ast->{-type};
-    }
+    my $tag = "_" . $ast->{-type};
     
     my $meth = $self->can($tag) || croak "Unknown tag '$tag'";
     return $meth->($self, $ast);