Little Moose Bug

It is quick fix postette day here in the Moose-Pen

Yesterday I left off with one fail in my '30_where_basic.t' test case


# Expected SQL--> SELECT people.first_name First, people.last_name Last,
people.user_id "User ID"
# Generated SQL-> SELECT people.first_name, people.last_name, people.user_id
FROM people

my alias on these Elements

[
{
name => 'first_name',
alias=> 'First',
},
{
name => 'last_name',
view => 'people',
alias=> 'Last'
},
{
name => 'user_id',
view => 'people',
alias=> 'User ID'
}
],

are not being adding into my 'SELECT' SQL.

This to me was a little odd as I though I had this covered in the '15_alias.t' test case which check for an SQL like this;


'SELECT sys_users.last_name "Last Name", sys_users.first_name "First Name" FROM people sys_users'

I wonder where the bug is. Using that little trick from the other day;

$utils->sql_param_ok( $in_hash,[ $tests->[8]] );

I isolated my testing to the last test re-ran the test and my error was

# Expected SQL--> SELECT people.first_name First, people.last_name Last, people.user_id "User ID" FROM people WHERE people.first_name != ? AND people.bonus * ? <= ? AND left(people.first_name,?) != ?
# Generated SQL-> SELECT people.first_name, people.last_name, people.user_id FROM people

So I was missing the conditions and I still had my default set of elements opp the error must be in the ' Test::Utils::sql_param_ok' sub I created, I guess incorrectly, yesterday. After a little debugging I found the error;

elsif ( exists( $test->{key} ) ) {
$in_hash->{ $test->{key} } = $test->{ $test->{key} };
}
elsif ( exists( $test->{keys} ) ) {
foreach my $key (@{$test->{keys}}) {
-- $in_hash->{ $test->{$key} } = $test->{ $test->{$key} };
++ $in_hash->{ $key } = $test->{$key };
}
}

and after that I get a full pass on the '30_where_basic.t'. At least I know my tests in '15_alias.t' are ok.

Good Times!

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