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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.