Null Moose

It is operator carry on day in the Moose-Pen

Just a quick postette on adding in another operator to Driver::DBI. Today I am adding the 'Is Null' operator. First of course a set of tests to add into '32_where_operators.t' along this vain;


{
caption => 'Is Null Operator Params',
key => 'conditions',
conditions => [
{
left => {
name => 'salary',
view => 'people'
},
operator => 'Is Null',
},
],
retrieve => {
sql =>
"SELECT people.first_name, people.last_name, people.user_id FROM people WHERE people.salary IS NULL",
params => [ '35000', '50000' ]
},


Note here how I have the operator 'Is Null' in mixed case as I know I can do that as I cover that in the Database::Driver code as it should convert it to upper case before it gets to the Driver::DBI. The only think special is on this condition I have no right operator which I think should work as the right is not a required field.

Now in Driver::DBI all I need to do extend that if statement in the '_predicate_sql' sub to cover the operator like this;



}
elsif (uc($predicate->operator) eq Database::Accessor::Driver::DBI::SQL::IS_NULL) {

$clause .= join(" ",$self->_field_sql($predicate->left,1)
,Database::Accessor::Driver::DBI::SQL::IS
,Database::Accessor::Driver::DBI::SQL::NULL
);

} elsif (uc($predicate->operator) eq Database::Accessor::Driver::DBI::SQL::BETWEEN) {

and after a few runs to fix a typo or two in the tests I get

...
ok 50 - Is Null Operator Params create SQL correct
ok 51 - Is Null Operator Params create params correct
ok 52 - Is Null Operator Params retrieve SQL correct
ok 53 - Is Null Operator Params update SQL correct
ok 54 - Is Null Operator Params delete SQL correct

Onto something else then.

rps77-d1a.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