Happy Sunny Moose Day

Quick postette day here in the Moose-Pen.

So yesterday I had left over SQL error that I wanted to have a look at. The error was

FROM locations WHERE <*>.city =

so I had no view in the where predicate;

$new_da->add_condition({left =>{ name => 'city',
right =>{ value => $other_user}

As I have saind in many previous posts I want to got give the DAD writer data that is as sanitized as possiable and therefor I should fix the above.

I first broke the code for setting the element on a view into is own private sub;

private_method check_view => sub {
my $self = shift;
my ($element) = @_;

unless ( $element->view() ) {
$element->view( $self->view->name() );
$element->view( $self->view()->alias() )
if ( $self->view()->alias() );


and then sub that in when I am checking the elements;

--            unless ( $element->view() ) {
--                $element->view( $self->view->name() );
--                $element->view( $self->view()->alias() )
--                  if ( $self->view()->alias() );
--            }
++            $self->check_view($element);

The is elements taken care of but what about the conditions? I really do not want to do a bunch of extra iteration over the conditions array so I added the following into the '_count_parentheses' sub

++ $self->check_view($predicate->right)
++ if(ref($predicate->right) eq 'Database::Accessor::Element');
++ $self->check_view($predicate->left)
++ if(ref($predicate->left) eq 'Database::Accessor::Element');

where I call the 'check_view' sub on both the left and right attribute of the predicate if the attribute is an 'element' class.

Now when I run the test script without a 'view' it works quite nicely. So onto other things on a nice sunny Sunday.


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