Does anyone know if Set::Object works with Class::DBI objects? I can't get it to work as expected. The test code at the end of this message gives the following output:
Set 1 is 236 large, and set 2 is 3113 large - confirmed with SQL
The intersect of set 1 and set 2 should contain 25 objects - confirmed with SQL
$set1->intersection( $set2 ) makes set 3 0 large
$set1->intersection( $set1, $set2 ) makes set 3 0 large
$set3->intersection( $set1, $set2 ) makes set 3 0 large
$set3->union( $set1, $set2 ) makes set 3 3349 large - so something must work under the hood
What the intersection should produce is effectively the result of ANDing the two clauses but it doesn't.
I am also having a problem with the Set::Object documentation. The intersection method is an instance method but the docs don't explain what instance I should be calling it on. As you can see from my output, I have tried all the obvious combinations
My test code is:
#!/usr/local/bin/perl -w ### MyClass::DBI contains simple Class::DBI initialisation for my data +base (Oracle) use base 'MyClass::DBI'; use strict; use Set::Object; use MyClass::Person; my $set1 = Set::Object->new(); my $set2 = Set::Object->new(); my $set3 = Set::Object->new(); $set1->insert( MyClass::Person->search_like( date_of_birth => '1965%' +) ); $set2->insert( MyClass::Person->search_like( place_of_birth => '%ON' ) + ); printf "Set 1 is %i large, and set 2 is %i large - confirmed with SQL +\n", $set1->size, $set2->size; printf "The intersect of set 1 and set 2 should contain 25 objects - c +onfirmed with SQL\n"; $set3 = $set1->intersection( $set2 ); printf "\$set1->intersection( \$set2 ) makes set 3 %i large\n", $set3- +>size; $set3 = $set1->intersection( $set1, $set2 ); printf "\$set1->intersection( \$set1, \$set2 ) makes set 3 %i large\n" +, $set3->size; $set3 = $set3->intersection( $set1, $set2 ); printf "\$set3->intersection( \$set1, \$set2 ) makes set 3 %i large\n" +, $set3->size; $set3 = $set3->union( $set1, $set2 ); printf "\$set3->union( \$set1, \$set2 ) makes set 3 %i large - so some +thing must work under the hood\n", $set3->size;
Could someone please advise?
Thanks,
fx
In reply to Set::Object's of Class::DBI objects by fx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |