Moose Fixes Second Bug
ts fix the other bug day here in the Moose-Pen.
The second of the bugs that I am after squishing today was in  Driver::DBI and in test case '15_alias.t'
It was dropping the elements/fields from the update command like this
Expected->UPDATE people SET first_name = ?
Generated -> UPDATE people SET 
Looking at the code in Driver::DBI the line in question is the '_update' sub;
    my (@field_sql) =
        $self->_insert_update_container( Database::Accessor::Constants::UPDATE,
        $container );
The first thing I checked was what was in the '$container' I was playing with. A line of two or waring and a run later it that turned out it was
container=$VAR1 = {};
an empty hash. Now that is a little concerning as you should not be able to do an update with an empty container. I moved the debugging back in the code to where the '_update' sub is called in the 'execute' sub
sub execute {
    my $self = shift;
    my ( $result, $action, $dbh, $container, $opt ) = @_;
    warn("execute container=".Dumper($container));
and it was empty there as well. I guess it is into the Database::Accessor and see what the value is before create the DAD. Now I am not going to boar you with the six or so warings I inserted into Database::Accessor but I did find my $container was going awry with this element;
Database::Accessor::Element= bless( {
                 'view' => 'sys_users',
                 'name' => 'first_name',
                 'alias' => 'First Name'
               }, 'Database::Accessor::Element' );
on this line
    next
          if ( ($field->view) and ($field->view ne $self->view()->name()));
so the view 'alias' view was buggering me up. The fix was simple enough;
    next
         if (($field->view) 
              and ($field->view ne $self->view()->name() 
                      and $field->view ne $self->view()->alias()));
Though it did take me some 45 mins to get the logic just right forgot that I should only 'next' when neither the view name and view alias match not when just one matches;
After a few mins of removing way to many lines of warings I finally get a full pass;
1..18
ok 1 - Basic table alias create SQL correct
...
ok 18 - Field alias with spaces delete SQL correct
Onto other things; even though for just a postette it still took me over an hour to debug.

 Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations
	            Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations
Leave a comment