| 420 | | |
| 421 | | my $count = Foo->count( [{status => 10}, -or => {name => 'Apple'}] ); |
| 422 | | # ==> select count(*) from mt_foo where foo_status = 10 or foo_name = 'Apple' |
| 423 | | is($count, 3, '-or count'); |
| 424 | | |
| 425 | | $count = Foo->count( [ { status => { '<=' => 20 }, name => 'Apple' }, -and_not => { status => 11 } ] ); |
| 426 | | # ==> select count(*) from mt_foo where (foo_status <= 20 and foo_name = 'Apple') and not (foo_status = 11) |
| 427 | | is($count, 1, '-and_not count'); |
| 428 | | |
| 429 | | $count = Foo->count( [ |
| | 420 | my @foos = map { Foo->load($_) } (1..5); # not a search |
| | 421 | |
| | 422 | my @res = Foo->load([ |
| | 423 | {status => 10}, |
| | 424 | -or => {name => 'Apple'}, |
| | 425 | ]); |
| | 426 | @res = sort { $a->id <=> $b->id } @res; |
| | 427 | # where foo_status = 10 or foo_name = 'Apple' |
| | 428 | are_objects(\@res, [ @foos[0,3,4] ], '-or results'); |
| | 429 | |
| | 430 | @res = Foo->load([ |
| | 431 | { status => { '<=' => 20 }, |
| | 432 | name => 'Apple' }, |
| | 433 | -and_not => { status => 11 }, |
| | 434 | ]); |
| | 435 | @res = sort { $a->id <=> $b->id } @res; |
| | 436 | # where (foo_status <= 20 and foo_name = 'Apple') and not (foo_status = 11) |
| | 437 | are_objects(\@res, [ $foos[4] ], '-and_not results'); |
| | 438 | |
| | 439 | @res = Foo->load([ |