is => 'rw',
isa => LogicEnum,
default => 'AND',
- coerce => 1
+ coerce => 1,
+ required => 1,
);
has visitor => (
builder => '_build_visitor',
);
+ has cmp => (
+ is => 'rw',
+ isa => 'Str',
+ default => '=',
+ required => 1,
+ );
+
+ our %CMP_MAP = (
+ '=' => '==',
+ );
method select(Str|ArrayRef|ScalarRef $from, ArrayRef|Str $fields,
WhereType $where?,
}
method field(Str $key, $value) returns (AST) {
+ my $op = $CMP_MAP{$self->cmp} || $self->cmp;
my $ret = {
-type => 'expr',
- op => '==',
+ op => $op,
args => [
{ -type => 'name', args => [$key] }
],
args => [ map {
{
-type => 'expr',
- op => '==',
+ op => $op,
args => [
{ -type => 'name', args => [$key] },
$self->value($_)
# acked by RIBASUSHI
stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )'
},
-);
-my @foo = (
#6
{
args => {cmp => "like"},
stmt => 'SELECT * FROM test WHERE ( a LIKE ? AND b LIKE ? )'
},
+);
+my @foo = (
#7
{
args => {logic => "or", cmp => "like"},