Moose Extends a little more

Its just a extend even more post-ette day here in the Moose Pen

Well going to start on another test case today this time '30_where_basic.t'. Now I do not have to test some of the more basic 'where' conditions as I have already proved that they work from all the other tests cases that use them so what I am going to start out with today is a function as part of a condtion;

First of course is my test;


my $user_db = Xtest::DB::Users->new();
my $dbh = $user_db->connect();
my $people = $user_db->new_person_data;
my $da = $person->da();

$da->add_condition( {
left => {
function => 'substr',
left => { name => 'first_name' },
right => [ { param => 1 }, { param => 5 } ]
},
right => { value => 'Tommy' },
operator => '=',
},);

$da->retrieve($dbh);

my $all_people = $user_db->people_data();
cmp_deeply( $da->result()->set, $all_people,
"All 4 users retrieved correctly with function");


Quite familiar by now and what I am selecting here are all the the rows in the people table where the first_name starts with 'Tommy'. That should give me the same set as what is in '$updated_people'. On my first run I get

not ok 1 - All 4 users retreived correctly
# Failed test 'All 4 users retreived correctly'
# at 30_where_basic.t line 36.
# Compared $data->[0][0]
# got : '9'
# expect : '6'

I think that is a case where the data is not coming out in the same order as the values in '$updated_people' I think this little patch will fix that;

my $da = $person->da();
++$da->add_sort({name=>'id'});
$da->add_condition( {

and now I get

ok 1 - All 4 users retrieved correctly with function

Well more comming tomorrow.

2mheN2c.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