Not getting unique data in an iterator.
[prev]
[thread]
[next]
[Date index for 2004/07/06]
--Signature=_Tue__6_Jul_2004_08_01_51_-0600_muQm=M_HKx.25Iah
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Hey All,
Using PostgreSQL 7.4.1, Perl 5.8.3, Class::DBI 0.96, DBI 1.43.
When executing the following, the data retrieved through the inner ($v_iter)
iterator is only the first row returned by the db query. $v_iter does loop the
correct number of times (48 with my db in this specific instance), but the
data is not changing during the loop.
Thanks,
Rob
#!/usr/bin/perl
use strict;
use warnings;
package TASSIV::DBI;
use base qw( Class::DBI );
__PACKAGE__->set_db( 'Main' => 'dbi:Pg:dbname=tassiv', 'robert', undef );
package TASSIV::Welch;
use base qw( TASSIV::DBI );
__PACKAGE__->table( 'welch_index' );
__PACKAGE__->columns( 'Primary' => 'star_id' );
__PACKAGE__->columns( 'Others' => qw/updated index/ );
__PACKAGE__->add_constructor( 'welch_gt' => 'index > ?' );
package TASSIV::Files;
use base qw( TASSIV::DBI );
__PACKAGE__->table( 'files' );
__PACKAGE__->columns( 'Primary' => 'file_id' );
__PACKAGE__->columns( 'Others' => qw/date/ );
__PACKAGE__->has_a( 'file_id' => 'TASSIV::Fits' );
package TASSIV::Fits;
use base qw( TASSIV::DBI );
__PACKAGE__->table( 'fits' );
__PACKAGE__->columns( 'Primary' => 'file_id' );
__PACKAGE__->columns( 'Others' => qw/adc loc darktime exptime/ );
package TASSIV::ObsV;
use base qw( TASSIV::DBI );
__PACKAGE__->table( 'obs_v' );
__PACKAGE__->columns( 'Primary' => 'star_id' );
__PACKAGE__->columns( 'Others' => qw/x y mag smag file_id/ );
__PACKAGE__->has_a( 'file_id' => 'TASSIV::Files' );
__PACKAGE__->has_a( 'star_id' => 'TASSIV::Catalog' );
package TASSIV::Catalog;
use base qw( TASSIV::DBI );
__PACKAGE__->table( 'catalog' );
__PACKAGE__->columns( 'Primary' => 'star_id' );
__PACKAGE__->columns( 'Others' => qw/loc_count loc/ );
__PACKAGE__->might_have( 'welch_index' => 'TASSIV::Welch' => 'index' );
__PACKAGE__->has_many( 'v' => 'TASSIV::ObsV' );
package main;
my $it = TASSIV::Welch->welch_gt( 200 );
while( my $star = $it->next )
{
printf "%s\n", join ', ',
map { sprintf "%s => %s", $_, $star->$_ } $star->columns;
my $obj = TASSIV::Catalog->retrieve( $star->star_id );
my $v_iter = $obj->v;
while( my $obs = $v_iter->next )
{
printf "\t%s\n", join ', ',
map { sprintf "%s => %s", $_, $obs->$_ } $obs->columns;
}
}
--
07:48:55 up 68 days, 14:33, 5 users, load average: 2.01, 2.05, 2.07
Linux 2.6.5-01 #7 SMP Fri Apr 16 22:45:31 MDT 2004
--Signature=_Tue__6_Jul_2004_08_01_51_-0600_muQm=M_HKx.25Iah
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iEYEARECAAYFAkDqsM8ACgkQLQ/DKuwDYzmgxwCePdhSjAgJNZ4yo81Eb2WKzXOr
Qu4AnjoJv3T1Ygpu1Z1WfUKfN40a4HPm
=iiqt
-----END PGP SIGNATURE-----
--Signature=_Tue__6_Jul_2004_08_01_51_-0600_muQm=M_HKx.25Iah--
|
Not getting unique data in an iterator.
Robert Creager 14:01 on 06 Jul 2004
|