name 'SQL-Abstract';
requires 'Moose' => '0.71';
-requires 'MooseX::Method::Signatures' => '0.13_804d1448';
-requires 'MooseX::Declare' => '0.09';
+requires 'MooseX::Declare' => '0.22';
requires 'MooseX::Types::Structured' => '0.09';
requires 'Devel::PartialDump' => '0.07';
test_requires 'Sub::Exporter';
auto_provides_class();
+json_meta();
auto_install;
tests_recursive 't';
use SQL::Abstract::Types qw/NameSeparator QuoteChars AST/;
use Devel::PartialDump qw/dump/;
- clean;
-
our $VERSION = '2.000000';
our $AST_VERSION = '1';
use SQL::Abstract::Types qw/AST/;
use Devel::PartialDump qw/dump/;
- clean;
-
# set things that are valid in where clauses
override _build_expr_dispatch_table {
return {
use Carp qw/croak/;
class_type 'SQL::Abstract';
- clean;
has logic => (
is => 'rw',
push @values, { -type => 'value', value => $fields->{$_} };
}
+ $ast->{where} = $self->recurse_where($where)
+ if defined $where;
+
return $ast;
}
};
}
- method recurse_where(WhereType $ast, LogicEnum $logic?) returns (AST) {
+ method recurse_where(WhereType $ast, LogicEnum $logic?) {
return $self->recurse_where_hash($logic || 'AND', $ast) if is_HashRef($ast);
return $self->recurse_where_array($logic || 'OR', $ast) if is_ArrayRef($ast);
croak "Unknown where clause type " . dump($ast);
}
# Deals with where({ .... }) case
- method recurse_where_hash(LogicEnum $logic, HashRef $ast) returns (AST) {
+ method recurse_where_hash(LogicEnum $logic, HashRef $ast) {
my @args;
my $ret = {
-type => 'expr',
}
# Deals with where([ .... ]) case
- method recurse_where_array(LogicEnum $logic, ArrayRef $ast) returns (AST) {
+ method recurse_where_array(LogicEnum $logic, ArrayRef $ast) {
my @args;
my $ret = {
-type => 'expr',
}
# { field => { .... } } case
- method field_hash(Str $key, HashRef $value) returns (AST) {
+ method field_hash(Str $key, HashRef $value) {
my ($op, @rest) = keys %$value;
confess "Don't know how to handle " . dump($value) . " (too many keys)"
};
}
- method field(Str $key, $value) returns (AST) {
+ method field(Str $key, $value) {
if (is_HashRef($value)) {
return $self->field_hash($key, $value);
return $ret;
}
- method value($value) returns (AST) {
+ method value($value) {
return $self->apply_convert( { -type => 'value', value => $value })
if is_Str($value);
use MooseX::Declare;
-class SQL::Abstract::Types {
+class SQL::Abstract::Types is dirty {
use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw/ArrayRef Str Int Ref HashRef/;
use MooseX::Declare;
-class SQL::Abstract::Types::Compat {
+class SQL::Abstract::Types::Compat is dirty {
use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw/ArrayRef Str Int Ref HashRef ScalarRef/;
} else {
&$test;
}
- is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
+ is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind}) or diag "On $_->{stmt}";
}
}
use Test::SQL::Abstract::Util qw/
mk_name
mk_value
- mk_expr
field_op_value
:dumper_sort
/;
use SQL::Abstract::Compat;
-use Test::More tests => 2;
+use Test::More tests => 3;
use Test::Differences;
ok(my $visitor = SQL::Abstract::Compat->new);
-my $foo_id = { -type => 'identifier', elements => [qw/foo/] };
-my $bar_id = { -type => 'identifier', elements => [qw/bar/] };
-
-my $foo_eq_1 = field_op_value($foo_id, '==', 1);
-my $bar_eq_str = field_op_value($bar_id, '==', 'some str');
-
eq_or_diff
$visitor->update_ast('test', { foo => 1 }),
{ -type => 'update',
},
"simple update";
+eq_or_diff
+ $visitor->update_ast('test', { foo => 1 }, { id => 2 }),
+ { -type => 'update',
+ tablespec => mk_name('test'),
+ columns => [
+ mk_name('foo')
+ ],
+ values => [
+ mk_value(1)
+ ],
+ where => field_op_value('id' => '==', 2)
+ },
+ "simple update";
+
+
+