Updates to MX::Declare required changes
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract.pm
index e04c863..e21f4ca 100644 (file)
@@ -8,11 +8,9 @@ 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;
-
   our $VERSION = '2.000000';
 
   our $AST_VERSION = '1';
@@ -24,13 +22,21 @@ 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 => (
@@ -73,11 +79,10 @@ class SQL::Abstract {
     required => 1
   );
 
-  has name_separator => ( 
+  has ident_separator => ( 
     is => 'rw', 
     isa => NameSeparator,
     default => '.',
-    coerece => 1,
     required => 1,
   );
 
@@ -91,9 +96,9 @@ class SQL::Abstract {
   has quote_chars => (
     is => 'rw', 
     isa => QuoteChars,
-    coerece => 1,
     predicate => 'is_quoting',
     clearer => 'disable_quoting', 
+    coerce => 1,
   );
 
   has binds => (
@@ -109,6 +114,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;
@@ -120,7 +126,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,17 +143,28 @@ 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);
   }
 
 };
+
+__END__
+
+=head1 NAME
+
+SQL::Abstract - AST based re-implementation of SQL::Abstract
+
+=head1 LICENSE
+
+=head1 AUTHORS
+
+Ash Berlin C<< <ash@cpan.org> >>
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+