Maybe Tomorow Moose?

Oh well! Still stuck in DA day here in the Moose-Pen.

Well I still have a little more work to do as I just read that you can have a 'case' in a 'Join/link' as this;


SELECT *
FROM sys.indexes i
JOIN sys.partitions p
ON i.index_id = p.index_id
JOIN sys.allocation_units a
ON CASE
WHEN a.type IN (1, 3)
THEN p.hobt_id
WHEN a.type IN (2)
THEN p.partition_id
ELSE NULL
END = a.container_id

is valid SQL. Well why get out of rut while you are in one so I will start with a new test in '45_dynamic_links.t'

$da->reset_links();
$in_hash = {
links => [
{
to => {
name => 'country',
alias => 'a_country'
},
type => 'left',
conditions => [
{
left => {whens => [
{
left => { name => 'Price', },
right => { value => '10' },
operator => '<',
statement => { name => 'price' }
},
{ statement => { name => 'prices' } }
]}
}
]

}
]
};
$da->add_link($in_hash->{links});
$da->retrieve( Data::Test->new(), $return );
ok( ref( $da->dynamic_links()->[0]->conditions->[0]->predicates->left ) eq "Database::Accessor::Case",
'dynamic_links()->[0]->conditions->[0]->predicates->left is a Case' );


Now on my first run I got what we have seen before;

Attribute (left) does not pass the type constraint because: Validation failed for
'ArrayRefofElements|ArrayRefofExpressions|ArrayRefofParams|Element|Expression|Function|Param'
with value { whens: [ HASH(0x435738c), HASH(0x4334f14) ] }

and after some poking about looking for the correct spot to enter in that missing 'Case' class and I guess I must of missed or flubbed up a change from yesterday as all I needed to add was 'Case' into the 'isa' of the 'left' attribute of my 'Database::Accessor::Roles::Comparators' class;

has left => (
is => 'rw',
-- isa =>'Expression|Param|Element|Function
|ArrayRefofParams|ArrayRefofElements
|ArrayRefofExpressions',
++ isa =>'Case|Expression|Param|Element|Function
|ArrayRefofParams
|ArrayRefofElements
|ArrayRefofExpressions',
required => 1,
coerce => 1,
);

and I get


ok 40 - DAD Dynamic Link 0->predicates 0 correct
ok 41 - dynamic_links()->[0]->conditions->[0]->predicates->left is a Case

So maybe tomorrow I will get to Driver::DBI??
IMG_6320a.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