Moose Extends More Tests


Moose Extends More Tests

Its Just a quick post-ette day here in the Moose-Pen

When we last met our hero she had gotten though most of the perils of the ever-changing API and the ever-increasing code base but found one other problem when working on the test in test case ’10_crud_basic.t’

$da = $person->da();


                left => {

                    name => 'user_id',


                right     => { value => $new_person->{user_id }},

                operator  => '=',



The $da->results->set was coming out a little wrong;


 'set' => [













            ]   ];


It is missing most of the elements. Fortunetly the ‘results’ object I can see the query da->results->query;

SELECT, people.first_name, people.last_name, people.user_id, assress_id,

 address.street,, address.postal_code, address.country_id, country.description country,

 region.description region, time_zone.description "time zone" 

  FROM people

LEFT JOIN people_address ON = people_address.address_id 

                                            AND people_address.primary_ind = ? 

LEFT JOIN address ON people_address.address_id = 

LEFT JOIN country ON = address.country_id 

LEFT JOIN region ON = address.region_id 

LEFT JOIN time_zone ON = address.time_zone_id 

WHERE people.user_id = ? 

and I revived it and I notices I had an incorrect join on that first ‘JOIN’ it should be;

LEFT JOIN people_address ON = people_address.people_id 

                                            AND people_address.primary_ind = ? 

So there is something awry going on there and the first place I looked was in my ‘Person’ class and I added in this little fix;

links => [{type       => 'LEFT',

           to         => { name => 'people_address'},

           conditions => [{ left      =>{ name => 'id', },

--                          right     =>{ name => 'address_id',}},

++                          right     =>{ name => 'people_id',}},

                          { condition =>'and',

                            left      => { name => 'primary_ind',

                                           view => 'people_address' },

                            right     => { value => 1}}


After the above change I get what I think is the correct record set;

 'set' => [[






       'Plaza de la Constitucion 2',

       'Ciudad de Mexico',


       '3 ',




so now I at least have at least more data coming back. The question is are they correct? I do have the input hash from ‘_new_person_data’ but that does not help me much as I have a hash vs an array. What I will have to do it add in the expected results to the ‘_people_data’ and the other functions that return data.

So a quick add in here;

sub _people_data {

      my $self = shift;

      return [[1,'Bill'     ,'Master','masterb' ,1,'1414 New lane','Toronto',


         [2,'Bob'      ,'Milk'   ,'milkb'   ,2,'22 Sicamore'  ,'Toronto',


         [3,'Jill'     ,'Nobert' ,'norbertj',3,'PO Box 122','Hollywood',

'90210'  ,1,'USA'   ,10,'West',3,'PST'],

         [4,'Alfred E.','Newman' ,'newmanae',4,'PO Box 233','Hollywood',

'90210'  ,1,'USA'   ,10,'West',3,'PST'],

++       [5,'James'    ,'Marceia','marceiaj',6,'Plaza de la Constitucion 23',

'Ciudad de Mexico','06000',3,'Mexico',21,'NA',2,'CST'],      


I also noticed when I was playing in there I was missing a few elements on my ‘Person’ class. So I added in two new elements ‘region_id’ and ‘time_zone_id’ to that and then added in this test;

 my $test_data = $user_db->_people_data->[4];

 cmp_deeply( $da->result()->set->[0], $test_data,

            "Return results correct");

and my result came out as

not ok 7 - Return results correct

#   Failed test 'Return results correct'

#   at 10_crud_basic.t line 75.

# Compared $data->[8]

#    got : '3 '

# expect : '3'

So my field ‘country_id’ is coming up as a string vs a int. I wonder where that come in to the mix. Looking at the DB and I see that both the ‘country_id’ and the ‘region_id’ as set as a CHAR(2) and really they should be a int. So I had to make a change to that how I build the db in ‘Xtest::DB::Users::Plugin::Oracle’ and once I made that change;

Now I get

ok 7 - Return results correct

All good for today and onto something else tomorrow.


Moose Extends More Tests

Using Node.js with JS-comint in Emacs


The Future Of Emerging Memories



Moose Extends More Tests