Start porting more back compat changes
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract.pm
index 3d6bd73..d987fd7 100644 (file)
@@ -1,16 +1,15 @@
 use MooseX::Declare;
 
-
 class SQL::Abstract {
 
   use Carp qw/croak/;
   use Data::Dump qw/pp/;
 
   use Moose::Util::TypeConstraints;
-  use MooseX::Types -declare => [qw/NameSeparator/];
   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;
 
@@ -26,12 +25,14 @@ class SQL::Abstract {
 
   our %BINOP_MAP = (
     '>' => '>',
+    '>=' => '>=',
     '<' => '<',
+    '<=' => '<=',
     '==' => '=',
     '!=' => '!=',
     # LIKE is always "field LIKE <value>"
-    '-like' => 'LIKE',
-    '-not_like' => 'NOT LIKE',
+    'like' => 'LIKE',
+    'not_like' => 'NOT LIKE',
   );
 
   has expr_dispatch_table => (
@@ -78,7 +79,6 @@ class SQL::Abstract {
     is => 'rw', 
     isa => NameSeparator,
     default => '.',
-    coerece => 1,
     required => 1,
   );
 
@@ -92,9 +92,9 @@ class SQL::Abstract {
   has quote_chars => (
     is => 'rw', 
     isa => QuoteChars,
-    coerece => 1,
     predicate => 'is_quoting',
     clearer => 'disable_quoting', 
+    coerce => 1,
   );
 
   has binds => (
@@ -110,6 +110,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 +122,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;
@@ -137,13 +138,8 @@ class SQL::Abstract {
   }
 
   method dispatch (AST $ast) {
-    # I want multi methods!
-    my $tag;
-    if (is_ArrayAST($ast)) {
-      ($tag = $ast->[0]) =~ s/^-/_/;
-    } else {
-      $tag = "_" . $ast->{-type};
-    }
+
+    my $tag = "_" . $ast->{-type};
     
     my $meth = $self->can($tag) || croak "Unknown tag '$tag'";
     return $meth->($self, $ast);