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 AST ArrayAST/;
+ use SQL::Abstract::Types qw/NameSeparator QuoteChars AST HashAST ArrayAST/;
+ use Devel::PartialDump qw/dump/;
clean;
'==' => '=',
'!=' => '!=',
# LIKE is always "field LIKE <value>"
- '-like' => 'IN',
+ '-like' => 'LIKE',
'-not_like' => 'NOT LIKE',
);
- has where_dispatch_table => (
+ has expr_dispatch_table => (
is => 'ro',
lazy => 1,
- builder => '_build_where_dispatch_table',
+ builder => '_build_expr_dispatch_table',
isa => HashRef[CodeRef],
metaclass => 'Collection::ImmutableHash',
provides => {
- get => 'lookup_where_dispatch'
+ get => 'lookup_expr_dispatch'
}
);
# List of default binary operators (for in where clauses)
sub _build_binops { return {%BINOP_MAP} };
- method _build_where_dispatch_table {
+ method _build_expr_dispatch_table {
my $binop = $self->can('_binop') or croak "InternalError: $self can't do _binop!";
return {
map { $_ => $binop } $self->binary_operators
has name_separator => (
is => 'rw',
isa => NameSeparator,
- default => sub { ['.'] },
+ default => '.',
coerece => 1,
required => 1,
);
required => 1,
);
+ has quote_chars => (
+ is => 'rw',
+ isa => QuoteChars,
+ coerece => 1,
+ predicate => 'is_quoting',
+ clearer => 'disable_quoting',
+ );
+
has binds => (
isa => ArrayRef,
is => 'ro',
}
# Main entry point
- method generate(ClassName $class: AST $ast) {
+ method generate(ClassName $class: HashAST $ast) {
+ my $ver = $ast->{-ast_version};
croak "SQL::Abstract AST version not specified"
- unless ($ast->[0] eq '-ast_version');
-
- my (undef, $ver) = splice(@$ast, 0, 2);
+ unless defined $ver;
# TODO: once MXMS supports %args, use that here
my $self = $class->create($ver);
}
method dispatch (AST $ast) {
+
+
# I want multi methods!
my $tag;
if (is_ArrayAST($ast)) {
- ($tag = $ast->[0]) =~ s/^-/_/;
+ confess "FIX: " . dump($ast);
} else {
$tag = "_" . $ast->{-type};
}