Remorseful Moose

If back-paddle postette day here in the Moose-Pen

My great re-factoing did not really work as well as expected. I has a suspicion, when I started working on the re-factoring, that I would have trouble with the 'parenthesis' check. I though the problem would crop us when adding two or more conditions on separate 'adds' where I open the parenthesis on the fist on and close it on the last.

Fortunately I had a test case, '43_dynamic_conditions.t ', that tests this situation exactly;


my $in_hash = {
conditions => [
{
left => {
name => 'last_name',
view => 'People'
},
right => { value => 'test' },
operator => '=',
open_parentheses => 1,
close_parentheses => 0,
condition => 'AND',
},
{
condition => 'AND',
left => {
name => 'first_name',
view => 'People'
},
right => { value => 'test' },
operator => '=',
open_parentheses => 0,
close_parentheses => 1
}
]

,
};

foreach my $condition ( @{ $in_hash->{conditions} } ) {
ok( $da->add_condition($condition), "can add an single Dynamic condition" );

}


In the above I try to add two conditions one with the open_parentheses and the other with close_parentheses but I get this fail;


Database::Accessor->dynamic Unbalanced parentheses in your dynamic attributes. Please check them! at D:\GitHub\database-accessor\lib/Database/Accessor.pm line 493.

The bug is in premis of the re-factoring itself not the code per-say. I can only check for an unbalanced parentheses in the dynamic conditions once I have all of them and I can only do that with iteration.

Given the the purpose of the re-factoring was to cut down on iteration by checking each dynamic element as it came in I am back to square one.

Oh well! Good thing I branched this.

sadmoose.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