9 use Moose::Util::TypeConstraints;
10 use MooseX::Types -declare => [qw/NameSeparator/];
11 use MooseX::Types::Moose qw/ArrayRef Str Int/;
12 use MooseX::AttributeHelpers;
16 subtype NameSeparator,
18 #where { @$_ == 1 ||| @$_ == 2 },
19 #message { "Name separator must be one or two elements" };
21 coerce NameSeparator, from Str, via { [ $_ ] };
23 our $VERSION = '2.000000';
25 our $AST_VERSION = '1';
27 # Operator precedence for bracketing
46 has name_separator => (
49 default => sub { ['.'] },
54 has list_separator => (
64 default => sub { [ ] },
65 metaclass => 'Collection::Array',
68 clear => '_clear_binds',
72 # TODO: once MXMS supports %args, use that here
73 method create(ClassName $class: Int $ver) {
74 croak "AST version $ver is greater than supported version of $AST_VERSION"
75 if $ver > $AST_VERSION;
77 my $name = "${class}::AST::v$ver";
78 Class::MOP::load_class($name);
80 return $name->new(ast_version => $ver);
84 method generate(ClassName $class: ArrayRef $ast) {
85 croak "SQL::Abstract AST version not specified"
86 unless ($ast->[0] eq '-ast_version');
88 my (undef, $ver) = splice(@$ast, 0, 2);
90 # TODO: once MXMS supports %args, use that here
91 my $self = $class->create($ver);
93 return ($self->dispatch($ast), $self->binds);