Penultimate Moose

Its penultimate operator day here in the Moose-Pen

This is just a quick postette today add in what I think is next to last special 'operator' the 'All' and as before I start with a test;


{
caption => 'Any Operator with Data::Accessor',
key => 'conditions',
conditions => [
{
left => {value=>Test::Utils::in_da_sql()},
operator => 'aLl',
},
],
create => {
container => $container,
sql =>
"INSERT INTO people ( first_name, last_name ) VALUES( ?, ? )",
params => $params
},
retrieve => {
sql =>
"SELECT people.first_name, people.last_name, people.user_id FROM people WHERE ALL (SELECT address.user_id FROM address WHERE address.country = ?)",
params => ['CA']
},
update => {
container => $container,
sql =>
"UPDATE people SET first_name = ?, last_name = ? WHERE ALL (SELECT address.user_id FROM address WHERE address.country = ?)",
params => [ 'Bill', 'Bloggings','CA' ]
},
delete => {
sql => "DELETE FROM people WHERE ALL (SELECT address.user_id FROM address WHERE address.country = ?)",
params => ['CA']
},
}

Next I need to add in the constants which I wont bother to show here as I we have seen them before and after that all I am going to try is just add in the new constant into the existing 'elsif' for 'Exists' as is shares the same calling pattern and the same validation;

elsif ($predicate->operator eq Database::Accessor::Driver::DBI::SQL::EXISTS
or $predicate->operator eq Database::Accessor::Driver::DBI::SQL::NOT_EXISTS
++ or $predicate->operator eq Database::Accessor::Driver::DBI::SQL::ALL) {

and here we go;
and that passes. I don't even need to add an validation but I should at least test that the 'All' come up on the error so here it is

{
caption => 'All left must be a Param with a value of DA-ref 2',
type => 'exception',
key => 'conditions',
conditions => [
{
left => { value=> 'cost' },
operator => 'All',
}],
retrieve =>
{ message => "'ALL' left must be a" },
},

now I have 122 tests that are all passing.

hp5122.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations