Skip Menu |
 
Update: The rt.cpan.org bug tracker service is no longer shutting down.

This queue is for tickets about the Class-DBI CPAN distribution.

Report information
The Basics
Id: 17805
Status: open
Priority: 0/
Queue: Class-DBI

People
Owner: Nobody in particular
Requestors: evdb [...] ecclestoad.co.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: v3.0.9
Fixed in: (no value)



Subject: Object not stored in objct index when created if PK comes from a sequence.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1140622588-23079-2"
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 948
Download (untitled) / with headers
text/plain 948b
This is from a mail I sent to the CDBI mailing list yesterday. Hello, a while back I posted a test script (attached) that showed up a bug in the object index that means that a new row whose PK comes from a sequence is not added to the index correctly, although this may only affect users of postgres. In the thread that followed a solution came to light that fixes this problem in 3.0.12: # Line 578 or so of Class/DBI.pm 3.0.14 # now that we have a complete primary key, add this to the # object index if ( $Weaken_Is_Available ) { $self = $class->_init( $self ); } Could this fix be added to the next release. Currently it very difficult to work with CDBI and new objects, especially in tests where you create one, change it and then find that it does not work. The previous discussion is archived here: http://lists.digitalcraftsmen.net/pipermail/classdbi/2005-November/000514.html Cheers, Edmund.
Subject: class-dbi-sequence-object-index-bug.t
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1140622588-23079-1"
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Type: application/x-troff; name="class-dbi-sequence-object-index-bug.t"
Content-Disposition: inline; filename="class-dbi-sequence-object-index-bug.t"
Content-Transfer-Encoding: base64
Content-Length: 3692
# This is a test to show unexpected behaviour with relation to 'only # one object in memory'. If a row is added to the database and the # value of it's primary key comes from a sequence then it is not # fetched properly from the object cache. The same behaviour is not # shown if a value is explicitly given for the primary key. I think # this is the problem anyway... # The tests below assume that there is a postgres database 'cdbi_test' # - SQLite does not have sequences and so I don't think that these # tests can be run against it. # Please let me know if there is anything else that I can do to help # you withthis bug ( at least I think it is a bug ). # Edmund von der Burg # evdb@ecclestoad.co.uk # http://ecclestoad.co.uk # see: # http://lists.digitalcraftsmen.net/pipermail/classdbi/2005-November/000514.html # for more details. use strict; use warnings; use Data::Dumper; use Test::More 'no_plan'; ############################################################################ package CDBI; use base 'Class::DBI'; CDBI->connection("dbi:Pg:dbname=cdbi_test"); CDBI->sequence('cdbi_id_seq'); ############################################################################ package Parent; use base 'CDBI'; use Data::Dumper; Parent->table('parents'); Parent->columns( Primary => qw(cdbi_id) ); Parent->columns( Others => qw(name) ); Parent->has_many( children => 'Child' ); sub create_sql { '' } ############################################################################ package Child; use base 'CDBI'; Child->table('children'); Child->columns( Primary => qw/cdbi_id/ ); Child->columns( Others => qw/parent/ ); Child->has_a( parent => 'Parent' ); sub create_sql { '' } ############################################################################ package main; diag "\$Class::DBI::VERSION: '" . $Class::DBI::VERSION . "'"; create_tables(); for my $cdbi_id ( 1_000_000, undef ) { diag ""; diag "using cdbi_id: ", defined $cdbi_id ? $cdbi_id : 'undef'; diag ""; # create a test parent. my $parent = Parent->create( { cdbi_id => $cdbi_id, name => 'test parent' } ); ok $parent, 'create test parent'; # create a test child. my $child = Child->create( { parent => $parent, } ); ok $child, 'create test child'; # do a test to see if an update to the parent is reflected in the # child's parent. is $parent->name, $child->parent->name, "names the same"; ok $parent->name('new name'), "change name"; is $parent->name, $child->parent->name, "names the same"; ok $parent->update, "update"; is $parent->name, $child->parent->name, "names the same"; ok $parent->dbi_commit, "dbi_commit"; is( $parent->name, $child->parent->name, "names the same" ) || diag Dumper { '$parent' => $parent, '$child->parent' => $child->parent }; # Cleanup. $parent->delete; Parent->dbi_commit; } delete_tables(); CDBI->dbi_commit; ############################################################################ sub create_tables { my $dbh = CDBI->db_Main; $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ m/^NOTICE/ }; # diag "Creating tables and sequence"; $dbh->do( <<"" ); create sequence cdbi_id_seq $dbh->do( <<"" ); create table parents ( cdbi_id int8 primary key, name text not null ) $dbh->do( <<"" ); create table children ( cdbi_id int8 primary key, parent int8 not null references parents ) } sub delete_tables { my $dbh = CDBI->db_Main; # diag "Destroying tables and sequence"; $dbh->do("drop table $_") for qw( children parents ); $dbh->do("drop sequence cdbi_id_seq"); }
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: local policy)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id A52454D82DC for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Wed, 22 Feb 2006 10:59:26 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 1556B4D816C for <bug-Class-DBI [...] rt.cpan.org>; Wed, 22 Feb 2006 10:59:25 -0500 (EST)
Received: (qmail 10580 invoked by alias); 22 Feb 2006 15:58:49 -0000
Received: from soto.kasei.com (HELO soto.kasei.com) (80.76.206.154) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 22 Feb 2006 07:58:46 -0800
Received: by soto.kasei.com (Postfix, from userid 1011) id 6FFD31C5DB; Wed, 22 Feb 2006 15:58:39 +0000 (GMT)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
User-Agent: Mutt/1.5.5.1+cvs20040105i
Return-Path: <tony [...] tmtm.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Wed, 22 Feb 2006 15:58:39 +0000
Message-Id: <20060222155839.GA19017 [...] soto.kasei.com>
To: Guest via RT <bug-Class-DBI [...] rt.cpan.org>
From: Tony Bowden <tony [...] tmtm.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-23079-1140623972-1987.17805-0-0 [...] rt.cpan.org>
Content-Length: 271
Download (untitled) / with headers
text/plain 271b
On Wed, Feb 22, 2006 at 10:36:30AM -0500, Guest via RT wrote: Show quoted text
> Could this fix be added to the next release.
Do you have a failing test case? If you do, I can put out a fix pretty quickly. If not you'll have to wait until I get a chance to make one up. Thanks, Tony
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: domain of edmund.vonderburg [...] gmail.com designates 64.233.182.200 as permitted sender)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org>
Reply-To: evdb [...] ecclestoad.co.uk
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ISO-8859-1
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id C2E364D82E8 for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Wed, 22 Feb 2006 11:28:01 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 577AD4D82E7 for <bug-Class-DBI [...] rt.cpan.org>; Wed, 22 Feb 2006 11:28:01 -0500 (EST)
Received: (qmail 19946 invoked by alias); 22 Feb 2006 16:27:24 -0000
Received: from nproxy.gmail.com (HELO nproxy.gmail.com) (64.233.182.200) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 22 Feb 2006 08:27:21 -0800
Received: by nproxy.gmail.com with SMTP id n29so962373nfc for <bug-Class-DBI [...] rt.cpan.org>; Wed, 22 Feb 2006 08:27:14 -0800 (PST)
Received: by 10.49.33.14 with SMTP id l14mr1915212nfj; Wed, 22 Feb 2006 08:27:13 -0800 (PST)
Received: by 10.48.243.15 with HTTP; Wed, 22 Feb 2006 08:27:13 -0800 (PST)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
Domainkey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=F6Me1GYuaRft8TPb8CRsVVUPtiB4IzlKKa5zM6BTI8/VKmGaqH80QOJVtEAmEQH8WBZR+NEGYUea3t7Q6RBROlB5uJkElBJxQ3rIOdqynx9sU9ZcBHb8P3+U9953N5/SLD6gUcJDfEx0lzDlDgXxXBGWsr2ocMzkrdZWyy3Kg1s=
Return-Path: <edmund.vonderburg [...] gmail.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Wed, 22 Feb 2006 16:27:13 +0000
Message-Id: <f0145aa60602220827p565ceb48p [...] mail.gmail.com>
To: bug-Class-DBI [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: "Edmund von der Burg" <edmund.vonderburg [...] gmail.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-23099-1140625686-444.17805-0-0 [...] rt.cpan.org>
Content-Length: 903
Download (untitled) / with headers
text/plain 903b
The test script that I sent along fails on my system when the PK comes from the sequence. I am running 3.0.14 with Postgres 8.1. I'm not sure how best to create a test script that can be packaged and released though as it requires a Postgres database to run. Perhaps the test script I sent along should be tweaked to make it look for an environment variable (eg 'CDBI_TEST_POSTGRES_DSN' )and skip the tests if it is not found. As the test script (should) clean up after itself it could be run against an existing database without prompting the user but that will probably cause lots of pain. Cheers, Edmund. On 22/02/06, tony@tmtm.com via RT <bug-Class-DBI@rt.cpan.org> wrote: Show quoted text
> Do you have a failing test case? > > If you do, I can put out a fix pretty quickly. If not you'll have to > wait until I get a chance to make one up.
-- In reality I'm evdb@ecclestoad.co.uk - http://ecclestoad.co.uk
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-23099-1140625686-444.17805-5-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: local policy)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <f0145aa60602220827p565ceb48p [...] mail.gmail.com> <rt-3.5.HEAD-23099-1140625686-444.17805-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 52CE04D82F4 for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Wed, 22 Feb 2006 12:32:16 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id D35BB4D82F6 for <bug-Class-DBI [...] rt.cpan.org>; Wed, 22 Feb 2006 12:32:15 -0500 (EST)
Received: (qmail 8343 invoked by alias); 22 Feb 2006 17:31:38 -0000
Received: from soto.kasei.com (HELO soto.kasei.com) (80.76.206.154) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 22 Feb 2006 09:31:36 -0800
Received: by soto.kasei.com (Postfix, from userid 1011) id 14F781C4A9; Wed, 22 Feb 2006 17:31:30 +0000 (GMT)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
User-Agent: Mutt/1.5.5.1+cvs20040105i
Return-Path: <tony [...] tmtm.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Wed, 22 Feb 2006 17:31:30 +0000
Message-Id: <20060222173129.GA19646 [...] soto.kasei.com>
To: "evdb [...] ecclestoad.co.uk via RT" <bug-Class-DBI [...] rt.cpan.org>
From: Tony Bowden <tony [...] tmtm.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-23089-1140629544-706.17805-0-0 [...] rt.cpan.org>
Content-Length: 555
Download (untitled) / with headers
text/plain 555b
On Wed, Feb 22, 2006 at 11:28:07AM -0500, evdb@ecclestoad.co.uk via RT wrote: Show quoted text
> I'm not sure how best to create a test script that can be packaged and > released though as it requires a Postgres database to run. Perhaps the > test script I sent along should be tweaked to make it look for an > environment variable (eg 'CDBI_TEST_POSTGRES_DSN' )and skip the tests > if it is not found.
Sorry - I missed the attachment as RT.cpan doesn't forward those on. There's already a Pg test in the CDBI distribution. Perhaps you could add this into that? Tony
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: domain of edmund.vonderburg [...] gmail.com designates 64.233.182.198 as permitted sender)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <f0145aa60602220827p565ceb48p [...] mail.gmail.com> <rt-3.5.HEAD-23099-1140625686-444.17805-5-0 [...] rt.cpan.org> <20060222173129.GA19646 [...] soto.kasei.com> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org>
Reply-To: evdb [...] ecclestoad.co.uk
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ISO-8859-1
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 5B94F4D80B6 for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Thu, 23 Feb 2006 04:16:51 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 07D404D80A1 for <bug-Class-DBI [...] rt.cpan.org>; Thu, 23 Feb 2006 04:16:50 -0500 (EST)
Received: (qmail 26397 invoked by alias); 23 Feb 2006 09:16:13 -0000
Received: from nproxy.gmail.com (HELO nproxy.gmail.com) (64.233.182.198) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 23 Feb 2006 01:16:11 -0800
Received: by nproxy.gmail.com with SMTP id p77so2598nfc for <bug-Class-DBI [...] rt.cpan.org>; Thu, 23 Feb 2006 01:16:05 -0800 (PST)
Received: by 10.48.244.12 with SMTP id r12mr2278552nfh; Thu, 23 Feb 2006 01:16:05 -0800 (PST)
Received: by 10.48.47.19 with HTTP; Thu, 23 Feb 2006 01:16:05 -0800 (PST)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
Domainkey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=N7rUKMGVIwWpSH5RejLBaI5vFZj/423UPw++fg4cSWt9SFuwATF8H2lZsSEPGhFoHcUWAnWd2cSo0J4YB7nktusk+VZX4V2MJlk1ONTBHn7ifyOmM8usUjYO5gF8Ql1gKoc0hJBtQVObzMmUg9SvbGR4/1WlkGb5jJ1u681Vut4=
Return-Path: <edmund.vonderburg [...] gmail.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Thu, 23 Feb 2006 09:16:05 +0000
Message-Id: <f0145aa60602230116q4d39e4dp [...] mail.gmail.com>
To: bug-Class-DBI [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: "Edmund von der Burg" <edmund.vonderburg [...] gmail.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-8860-1140686215-153.17805-0-0 [...] rt.cpan.org>
Content-Length: 860
Download (untitled) / with headers
text/plain 860b
I did not realize that there was a Pg test script. I'll take the tests that I have and see if I can add them to that. Cheers, Edmund. On 22/02/06, tony@tmtm.com via RT <bug-Class-DBI@rt.cpan.org> wrote: Show quoted text
> On Wed, Feb 22, 2006 at 11:28:07AM -0500, evdb@ecclestoad.co.uk via RT wrote:
> > I'm not sure how best to create a test script that can be packaged and > > released though as it requires a Postgres database to run. Perhaps the > > test script I sent along should be tweaked to make it look for an > > environment variable (eg 'CDBI_TEST_POSTGRES_DSN' )and skip the tests > > if it is not found.
> > > Sorry - I missed the attachment as RT.cpan doesn't forward those on. > > There's already a Pg test in the CDBI distribution. Perhaps you could > add this into that? > > Tony > > >
-- In reality I'm evdb@ecclestoad.co.uk - http://ecclestoad.co.uk
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <f0145aa60602230116q4d39e4dp [...] mail.gmail.com>
Received-SPF: pass (x1.develooper.com: domain of edmund.vonderburg [...] gmail.com designates 64.233.182.201 as permitted sender)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <f0145aa60602220827p565ceb48p [...] mail.gmail.com> <rt-3.5.HEAD-23099-1140625686-444.17805-5-0 [...] rt.cpan.org> <20060222173129.GA19646 [...] soto.kasei.com> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org> <f0145aa60602230116q4d39e4dp [...] mail.gmail.com>
Reply-To: evdb [...] ecclestoad.co.uk
Content-Type: multipart/mixed; boundary="----=_Part_8418_3892426.1140713744649"
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id B79924D834E for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Thu, 23 Feb 2006 11:56:37 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id F2DA84D834B for <bug-Class-DBI [...] rt.cpan.org>; Thu, 23 Feb 2006 11:56:34 -0500 (EST)
Received: (qmail 9142 invoked by alias); 23 Feb 2006 16:55:57 -0000
Received: from nproxy.gmail.com (HELO nproxy.gmail.com) (64.233.182.201) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 23 Feb 2006 08:55:53 -0800
Received: by nproxy.gmail.com with SMTP id l24so65086nfc for <bug-Class-DBI [...] rt.cpan.org>; Thu, 23 Feb 2006 08:55:45 -0800 (PST)
Received: by 10.49.18.20 with SMTP id v20mr2405816nfi; Thu, 23 Feb 2006 08:55:44 -0800 (PST)
Received: by 10.48.47.19 with HTTP; Thu, 23 Feb 2006 08:55:44 -0800 (PST)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
Domainkey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=szwtu4UT6e4TlqQKuirYyOl6c+qmNFzL78yL/s86UOCao3gSwO5zlJnD0oM+tWJSkVj+x7SOlKCMbUk7u9iZPnlzXstxY6vJuJoWSSO612bWbPOfl4bP2Yjbwx8RUmW8H39o/PRguVMirHQo/izq3Ty1hXOxKRxCkRALH5AbZBE=
Return-Path: <edmund.vonderburg [...] gmail.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Thu, 23 Feb 2006 16:55:44 +0000
Message-Id: <f0145aa60602230855n2c08ad75j [...] mail.gmail.com>
To: bug-Class-DBI [...] rt.cpan.org
From: "Edmund von der Burg" <edmund.vonderburg [...] gmail.com>
RT-Message-ID: <rt-3.5.HEAD-8865-1140713802-377.17805-0-0 [...] rt.cpan.org>
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: ISO-8859-1
X-RT-Original-Encoding: utf-8
Content-Length: 483
Download (untitled) / with headers
text/plain 483b
Show quoted text
> > There's already a Pg test in the CDBI distribution. Perhaps you could > > add this into that?
I've created a new test file '27-pg_sequences.t' but it is based on the 'PgBase' that you use in Binary.pm so it should behave : ) Class::DBI fails the test, but passes after the code suggested in the test is added. Thanks for looking at this so quickly, anything else I can do give me a shout. Cheers, Edmund. -- In reality I'm evdb@ecclestoad.co.uk - http://ecclestoad.co.uk
content-type: application/x-troff; name="27-pg_sequences.t"
content-disposition: attachment; filename="27-pg_sequences.t"
Content-Transfer-Encoding: 7bit
X-Attachment-Id: f_ek1behmt
Content-Length: 3768
Download 27-pg_sequences.t
text/x-perl 3.6k

Message body is not shown because sender requested not to inline it.

X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-8865-1140713802-377.17805-5-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: local policy)
References: <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <f0145aa60602220827p565ceb48p [...] mail.gmail.com> <rt-3.5.HEAD-23099-1140625686-444.17805-5-0 [...] rt.cpan.org> <20060222173129.GA19646 [...] soto.kasei.com> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org> <f0145aa60602230116q4d39e4dp [...] mail.gmail.com> <f0145aa60602230855n2c08ad75j [...] mail.gmail.com> <rt-3.5.HEAD-8865-1140713802-377.17805-5-0 [...] rt.cpan.org>
Reply-To: tony [...] kasei.com
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id 82B0F4D80C9 for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Fri, 3 Mar 2006 03:49:17 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 27EB64D8084 for <bug-Class-DBI [...] rt.cpan.org>; Fri, 3 Mar 2006 03:49:17 -0500 (EST)
Received: (qmail 7975 invoked by alias); 3 Mar 2006 08:49:16 -0000
Received: from soto.kasei.com (HELO soto.kasei.com) (80.76.206.154) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 03 Mar 2006 00:49:14 -0800
Received: by soto.kasei.com (Postfix, from userid 1011) id B029D1C5AA; Fri, 3 Mar 2006 08:49:07 +0000 (GMT)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
User-Agent: Mutt/1.5.5.1+cvs20040105i
Return-Path: <tony [...] kasei.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Fri, 3 Mar 2006 08:49:07 +0000
Message-Id: <20060303084907.GA11290 [...] soto.kasei.com>
To: "evdb [...] ecclestoad.co.uk via RT" <bug-Class-DBI [...] rt.cpan.org>
From: Tony Bowden <tony [...] kasei.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-31820-1141375760-1132.17805-0-0 [...] rt.cpan.org>
Content-Length: 567
Download (untitled) / with headers
text/plain 567b
On Thu, Feb 23, 2006 at 11:56:44AM -0500, evdb@ecclestoad.co.uk via RT wrote: Show quoted text
> Thanks for looking at this so quickly, anything else I can do give me a shout.
Just as an update- I haven't forgotten about this. I'm hoping to use the opportunity to tidy up the entire object index code and move it out into another class which can be switched out for an alternative / subclassed etc. This means it will take slightly longer, but I will try to ensure that there is a fix in the new release, even if I just have to fall back on yours for the time being. Thanks, Tony
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.5.HEAD-31820-1141375760-1132.17805-6-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: domain of edmund.vonderburg [...] gmail.com designates 64.233.182.198 as permitted sender)
References: <RT-Ticket-17805 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <20060222173129.GA19646 [...] soto.kasei.com> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org> <f0145aa60602230116q4d39e4dp [...] mail.gmail.com> <f0145aa60602230855n2c08ad75j [...] mail.gmail.com> <rt-3.5.HEAD-8865-1140713802-377.17805-5-0 [...] rt.cpan.org> <20060303084907.GA11290 [...] soto.kasei.com> <rt-3.5.HEAD-31820-1141375760-1132.17805-6-0 [...] rt.cpan.org>
Reply-To: evdb [...] ecclestoad.co.uk
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: ISO-8859-1
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id E099D4D80C9 for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Fri, 3 Mar 2006 04:21:50 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 9A3154D80C8 for <bug-Class-DBI [...] rt.cpan.org>; Fri, 3 Mar 2006 04:21:50 -0500 (EST)
Received: (qmail 18060 invoked by alias); 3 Mar 2006 09:21:49 -0000
Received: from nproxy.gmail.com (HELO nproxy.gmail.com) (64.233.182.198) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 03 Mar 2006 01:21:42 -0800
Received: by nproxy.gmail.com with SMTP id h2so428322nfe for <bug-Class-DBI [...] rt.cpan.org>; Fri, 03 Mar 2006 01:21:37 -0800 (PST)
Received: by 10.48.203.19 with SMTP id a19mr1072286nfg; Fri, 03 Mar 2006 01:21:36 -0800 (PST)
Received: by 10.48.243.19 with HTTP; Fri, 3 Mar 2006 01:21:36 -0800 (PST)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
Domainkey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BuR5ElNPETDUiatPs3QdDBawkoR8VAidNzzFioIfBepei7nLRCpx2bFDQIpnRsQcQrdHZXCMZCgB+8gcpJOQO1gEMLdZn7e2iOTX+NPLP2Nan+ELsWxF/MW+0O6EIIC4W+UGcDW/GZCxaDAyYMcDmQwfguuow63BOkYyzFcXoec=
Return-Path: <edmund.vonderburg [...] gmail.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Fri, 3 Mar 2006 09:21:36 +0000
Message-Id: <f0145aa60603030121icbf0569m [...] mail.gmail.com>
To: bug-Class-DBI [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: "Edmund von der Burg" <edmund.vonderburg [...] gmail.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-31812-1141377715-331.17805-0-0 [...] rt.cpan.org>
Content-Length: 1725
Download (untitled) / with headers
text/plain 1.6k
No problems - I have a hack in place on my local system. Refactoring the object index sounds like a good idea. I was thinking a while back that it might be interesting to put the index into something like MMap so that it is accessible from several processes, although I decided that that was probably a dangerous thing to consider : ) Whilst you're hitting the code one thing that would be really useful (for me at least) would be able to do something like this: my $film = Film->insert({...}); # Update film over web interface ... # check that the film has been updated. $film->refresh; is $film->title, 'Jaws 19', '...'; Quite often I change the values in the database using some other process (eg updating over web) and then want to refresh the values in my local object. At the moment I tend to use: $film = $film->retrieve( $film->id ); which is clunky. Something like $film->refresh would be very useful. I really appreciate that you are maintaining CDBI. Cheers, Edmund. On 03/03/06, Tony Bowden via RT <bug-Class-DBI@rt.cpan.org> wrote: Show quoted text
> On Thu, Feb 23, 2006 at 11:56:44AM -0500, evdb@ecclestoad.co.uk via RT wrote:
> > Thanks for looking at this so quickly, anything else I can do give me a shout.
> > Just as an update- I haven't forgotten about this. I'm hoping to use the > opportunity to tidy up the entire object index code and move it out into > another class which can be switched out for an alternative / subclassed > etc. > > This means it will take slightly longer, but I will try to ensure that > there is a fix in the new release, even if I just have to fall back on > yours for the time being. > > Thanks, > > Tony > >
-- In reality I'm evdb@ecclestoad.co.uk - http://ecclestoad.co.uk
MIME-Version: 1.0
In-Reply-To: <rt-3.5.HEAD-31820-1141375760-1132.17805-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
References: <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <f0145aa60602220827p565ceb48p [...] mail.gmail.com> <rt-3.5.HEAD-23099-1140625686-444.17805-5-0 [...] rt.cpan.org> <20060222173129.GA19646 [...] soto.kasei.com> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org> <f0145aa60602230116q4d39e4dp [...] mail.gmail.com> <f0145aa60602230855n2c08ad75j [...] mail.gmail.com> <rt-3.5.HEAD-8865-1140713802-377.17805-5-0 [...] rt.cpan.org> <20060303084907.GA11290 [...] soto.kasei.com> <rt-3.5.HEAD-31820-1141375760-1132.17805-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.5.HEAD-2560-1142290214-559.17805-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: "Ryan Gerry" <gerryster [...] gmail.com>
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 1765
Download (untitled) / with headers
text/plain 1.7k
I also independently discovered this issue with the object index and creation without a primary key. I am using MySQL with a table that has an auto incrementing column. I was about to submit the bug when I found that the issue had already been submitted! I agree that separating out the object indexing code into another class would be a good idea. I also wanted to let you know that this object indexing idea has been documented as a design pattern in Martin Fowler's book "Patterns of Enterprise Application Architecture". Fowler calls this an "Identity Map". Here is a link to the synopsis of this pattern, but the full text is available in the book: http://www.martinfowler.com/eaaCatalog/identityMap.html I hope this link can provide you with inspiration as you proceed with the refactoring. The challenges with this pattern include concurrency issues. However, if the identity map only concerns itself with the uniqueness of object in memory of the current process or thread then these issues should be mitigated. From my experience, Ruby On Rail's ActiveRecord is missing this feature. On Fri Mar 03 03:49:20 2006, tony@kasei.com wrote: Show quoted text
> On Thu, Feb 23, 2006 at 11:56:44AM -0500, evdb@ecclestoad.co.uk via RT > wrote:
> > Thanks for looking at this so quickly, anything else I can do give
> me a shout. > > Just as an update- I haven't forgotten about this. I'm hoping to use > the > opportunity to tidy up the entire object index code and move it out > into > another class which can be switched out for an alternative / > subclassed > etc. > > This means it will take slightly longer, but I will try to ensure that > there is a fix in the new release, even if I just have to fall back on > yours for the time being. > > Thanks, > > Tony
X-Scanned-BY: AMaViS-ng at bestpractical
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.5.HEAD-2560-1142290214-559.17805-5-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: local policy)
References: <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org> <f0145aa60602230116q4d39e4dp [...] mail.gmail.com> <f0145aa60602230855n2c08ad75j [...] mail.gmail.com> <rt-3.5.HEAD-8865-1140713802-377.17805-5-0 [...] rt.cpan.org> <20060303084907.GA11290 [...] soto.kasei.com> <rt-3.5.HEAD-31820-1141375760-1132.17805-5-0 [...] rt.cpan.org> <rt-3.5.HEAD-2560-1142290214-559.17805-5-0 [...] rt.cpan.org>
Reply-To: tony [...] kasei.com
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from localhost (localhost.localdomain [127.0.0.1]) by diesel.bestpractical.com (Postfix) with ESMTP id EB8A34D807D for <cpan-bug+class-dbi [...] diesel.bestpractical.com>; Tue, 14 Mar 2006 01:45:46 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 80D324D8013 for <bug-Class-DBI [...] rt.cpan.org>; Tue, 14 Mar 2006 01:45:46 -0500 (EST)
Received: (qmail 10671 invoked by alias); 14 Mar 2006 06:45:43 -0000
Received: from soto.kasei.com (HELO soto.kasei.com) (80.76.206.154) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Mon, 13 Mar 2006 22:45:38 -0800
Received: by soto.kasei.com (Postfix, from userid 1011) id B8FCA1C42F; Tue, 14 Mar 2006 06:45:30 +0000 (GMT)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
User-Agent: Mutt/1.5.5.1+cvs20040105i
Return-Path: <tony [...] kasei.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Date: Tue, 14 Mar 2006 06:45:30 +0000
Message-Id: <20060314064530.GA28001 [...] soto.kasei.com>
To: Guest via RT <bug-Class-DBI [...] rt.cpan.org>
From: Tony Bowden <tony [...] kasei.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.5.HEAD-12314-1142318751-1267.17805-0-0 [...] rt.cpan.org>
Content-Length: 532
Download (untitled) / with headers
text/plain 532b
On Mon, Mar 13, 2006 at 05:50:16PM -0500, Guest via RT wrote: Show quoted text
> I also independently discovered this issue with the object index and > creation without a primary key. I am using MySQL with a table that has > an auto incrementing column. I was about to submit the bug when I found > that the issue had already been submitted!
A test case for that would be useful if you could put one together. However, this one surprises me as I believed the code coped with that. Is this still present in the latest CPAN release? Thanks, Tony
MIME-Version: 1.0
Subject: Object not stored in object index when created if PK comes from a sequence.
In-Reply-To: <rt-3.5.HEAD-12314-1142318751-1267.17805-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
References: <rt-3.5.HEAD-23079-1140622590-1782.17805-4-0 [...] rt.cpan.org> <20060222155839.GA19017 [...] soto.kasei.com> <rt-3.5.HEAD-23079-1140623972-1987.17805-6-0 [...] rt.cpan.org> <rt-3.5.HEAD-23089-1140629544-706.17805-6-0 [...] rt.cpan.org> <f0145aa60602230116q4d39e4dp [...] mail.gmail.com> <f0145aa60602230855n2c08ad75j [...] mail.gmail.com> <rt-3.5.HEAD-8865-1140713802-377.17805-5-0 [...] rt.cpan.org> <20060303084907.GA11290 [...] soto.kasei.com> <rt-3.5.HEAD-31820-1141375760-1132.17805-5-0 [...] rt.cpan.org> <rt-3.5.HEAD-2560-1142290214-559.17805-5-0 [...] rt.cpan.org> <20060314064530.GA28001 [...] soto.kasei.com> <rt-3.5.HEAD-12314-1142318751-1267.17805-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.5.HEAD-12311-1142354880-930.17805-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1142354880-12311-4"
From: "Ryan Gerry" <gerryster [...] gmail.com>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1581
Download (untitled) / with headers
text/plain 1.5k
Show quoted text
> > A test case for that would be useful if you could put one together. > However, this one surprises me as I believed the code coped with that. > Is this still present in the latest CPAN release? >
Attached is a test case which demonstrates the issue for MySQL. MySQL differs from Postgres in that it uses auto_increment columsn instead of sequences, but the basic idea is that same. The meat of the script is in the line: is(refaddr($obj1), refaddr($obj2), 'objects 1 and 2 are equivalent'); However, I provided an update case to exemplify the problem. I tested with Class-DBI-v3.0.14 (latest CPAN release). Here are my test results: perl ./class-dbi-sequence-object-index-bug-mysql.t 1..18 ok 1 - correct name ok 2 - correct value ok 3 - objects 1 and 2 are equivilent ok 4 - same field: id = 1 ok 5 - same field: name = foo ok 6 - same field: value = bar ok 7 - same field: id = 1 ok 8 - same field: name = foo ok 9 - same field: value = baz ok 10 - correct name ok 11 - correct value not ok 12 - objects 1 and 2 are equivilant # Failed test 'objects 1 and 2 are equivilant' # in ./class-dbi-sequence-object-index-bug-mysql.t at line 68. # got: '9292480' # expected: '9293092' ok 13 - same field: id = 2 ok 14 - same field: name = foo ok 15 - same field: value = bar ok 16 - same field: id = 2 ok 17 - same field: name = foo not ok 18 - same field: value = bar # Failed test 'same field: value = bar' # in ./class-dbi-sequence-object-index-bug-mysql.t at line 85. # got: 'baz' # expected: 'bar' # Looks like you failed 2 tests of 18.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: multipart/mixed; boundary="----------=_1142354880-12311-3"
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Type: application/x-troff; name="class-dbi-sequence-object-index-bug-mysql.t"
Content-Disposition: inline; filename="class-dbi-sequence-object-index-bug-mysql.t"
Content-Transfer-Encoding: base64
Content-Length: 2991
# Test case for http://rt.cpan.org/Public/Bug/Display.html?id=17805 and MySQL. # Tested with MySQL 4.1.14-max-log. However, the MySQL version should not be # very important since no advanced functionality is used. # # Connection information should be supplied using the DBI_DSN, DBI_USER, and # DBI_PASS environment variables. # # The basic problem is that insert could add the object to the object cache # when the object's table contains an auto incrementing primary key. This is # because this information is avialable when the row is inserted. use warnings; use strict; use Test::More tests => 18; use Class::DBI; use Scalar::Util qw(refaddr); # used to find the memory location of CDBI objects my $TABLE = 'test_CDBI'; #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::. package CDBI; use base 'Class::DBI'; __PACKAGE__->table($TABLE); __PACKAGE__->columns(Primary => qw/id/); __PACKAGE__->columns(Essential => qw/name value/); # use environment variables $DBI_DSN, $DBI_USER, and $DBI_PASS if avialable __PACKAGE__->connection($ENV{DBI_DSN} || 'DBI:mysql:database=test', $ENV{DBI_USER} || 'root', $ENV{DBI_PASS}); package main; #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::. sub startup { # create a table for the test class my $dbh = CDBI->db_Main; $dbh->do( <<"" ); CREATE TEMPORARY TABLE $TABLE ( id int(11) NOT NULL auto_increment PRIMARY KEY, name varchar(50), value varchar(50) ) } startup(); # NOTE: unless the unique key is passed to create (id => 1 in this case), # the identity map will not work and retrieving this object will result in # this object being loaded into memory twice # # The first value of $attr represents the passing case, the second is the # failing case. foreach my $attr ({ id => 1, name => 'foo', value => 'bar'}, { name => 'foo', value => 'bar'} ) { my $obj1 = CDBI->insert($attr); is($obj1->name, 'foo', 'correct name'); is($obj1->value, 'bar', 'correct value'); # retreive the object - expect a reference to $obj1 to be returned my $obj2 = CDBI->retrieve( $obj1->id ); # the two objects should be equivilant in memory # refaddr is helpful for getting the memory address since simply Class::DBI # overloads every operation. is(refaddr($obj1), refaddr($obj2), 'objects 1 and 2 are equivalent'); # test all of the common fields: check_fields($obj1, $obj2, qw/id name value/); # If the two objects are equal in memroy, updating one should update both. # This is not the case when the unique id is not passed to insert $obj2->value('baz'); $obj2->update; check_fields($obj1, $obj2, qw/id name value/); } #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::. sub check_fields { my ($obj1, $obj2, @fields) = @_; foreach my $field (@fields) { is($obj2->$field, $obj1->$field, "same field: $field = " . $obj1->$field); } }
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-12366-1156063796-810.17805-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 282
Download (untitled) / with headers
text/plain 282b
This isn't as simple as it appeared. It causes spurious warnings with t/11 and t/22. 22 seems to be related to attributes being set in before create triggers. I'm not sure what 11 is yet. I'll have another look later, but it means I couldn't put this in the latest release. Tony
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.4 required=8.0 tests=BAYES_00,DK_SIGNED,DK_VERIFIED,DNS_FROM_RFC_ABUSE,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-12366-1156063796-810.17805-6-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: domain of edmund.vonderburg [...] gmail.com designates 66.249.92.174 as permitted sender)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.6.HEAD-12366-1156063796-810.17805-6-0 [...] rt.cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
Received: from la.mx.develooper.com (ss1.fabel.dk [63.251.223.179]) by diesel.bestpractical.com (Postfix) with SMTP id 631784D80D9 for <bug-Class-DBI [...] rt.cpan.org>; Sun, 20 Aug 2006 06:41:43 -0400 (EDT)
Received: (qmail 32113 invoked by alias); 20 Aug 2006 10:41:42 -0000
Received: from ug-out-1314.google.com (HELO ug-out-1314.google.com) (66.249.92.174) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sun, 20 Aug 2006 03:41:40 -0700
Received: by ug-out-1314.google.com with SMTP id e2so1332230ugf for <bug-Class-DBI [...] rt.cpan.org>; Sun, 20 Aug 2006 03:41:34 -0700 (PDT)
Received: by 10.66.219.11 with SMTP id r11mr2843080ugg; Sun, 20 Aug 2006 03:41:34 -0700 (PDT)
Received: by 10.67.23.15 with HTTP; Sun, 20 Aug 2006 03:41:34 -0700 (PDT)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
Domainkey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=P8G6o1xMZrTazxQxHrfyX0Pz6U2C46q7D5K+L1Z5FiBiRPZGfp9+1teO3RDm2FvIBdznByVHyTv3heYrSWlu7YqZidWv58Q9d8BtBcPl12t/HaAHXlWcrPr65KXj6XN2R6l17vVGt5Hevxj39EUqpf7oO8s1mmDg9pW6JZEmd8U=
Return-Path: <edmund.vonderburg [...] gmail.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: bug-Class-DBI [...] rt.cpan.org
X-Google-Sender-Auth: c05ebe0d03f3a217
Sender: edmund.vonderburg [...] gmail.com
Date: Sun, 20 Aug 2006 11:41:34 +0100
Message-Id: <f0145aa60608200341uebfaa12i39dc81d725381a08 [...] mail.gmail.com>
To: bug-Class-DBI [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: "Edmund von der Burg" <evdb [...] ecclestoad.co.uk>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.6.HEAD-12366-1156070507-919.17805-0-0 [...] rt.cpan.org>
Content-Length: 731
Download (untitled) / with headers
text/plain 731b
Sorry that it is causing trouble : ) Once i made the changes that I suggested it worked for me - but I probably didn't exercise the code as thoroughly as you are. If there is anything that I can do to help please let me know. Cheers, Edmund On 20/08/06, via RT <bug-Class-DBI@rt.cpan.org> wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=17805 > > > This isn't as simple as it appeared. It causes spurious warnings with > t/11 and t/22. 22 seems to be related to attributes being set in before > create triggers. I'm not sure what 11 is yet. > > I'll have another look later, but it means I couldn't put this in the > latest release. > > Tony > >
-- In reality I'm evdb@ecclestoad.co.uk - http://ecclestoad.co.uk
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.6.HEAD-12366-1156070507-919.17805-5-0 [...] rt.cpan.org>
Content-Disposition: inline
Received-SPF: pass (x1.develooper.com: local policy)
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.6.HEAD-12366-1156063796-810.17805-6-0 [...] rt.cpan.org> <f0145aa60608200341uebfaa12i39dc81d725381a08 [...] mail.gmail.com> <rt-3.6.HEAD-12366-1156070507-919.17805-5-0 [...] rt.cpan.org>
Reply-To: tony [...] kasei.com
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from la.mx.develooper.com (ss1.fabel.dk [63.251.223.179]) by diesel.bestpractical.com (Postfix) with SMTP id C62A44D810A for <bug-Class-DBI [...] rt.cpan.org>; Sun, 20 Aug 2006 07:12:46 -0400 (EDT)
Received: (qmail 11209 invoked by alias); 20 Aug 2006 11:12:45 -0000
Received: from soto.kasei.com (HELO soto.kasei.com) (80.76.206.154) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sun, 20 Aug 2006 04:12:43 -0700
Received: by soto.kasei.com (Postfix, from userid 1011) id 38FE51C9C4; Sun, 20 Aug 2006 12:12:36 +0100 (BST)
Delivered-To: cpan-bug+class-dbi [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #17805] Object not stored in objct index when created if PK comes from a sequence.
User-Agent: Mutt/1.5.5.1+cvs20040105i
Return-Path: <tony [...] kasei.com>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: bug-Class-DBI [...] rt.cpan.org
Date: Sun, 20 Aug 2006 12:12:36 +0100
Message-Id: <20060820111236.GA16934 [...] soto.kasei.com>
To: "evdb [...] ecclestoad.co.uk via RT" <bug-Class-DBI [...] rt.cpan.org>
From: Tony Bowden <tony [...] kasei.com>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.6.HEAD-12366-1156072455-345.17805-0-0 [...] rt.cpan.org>
Content-Length: 910
Download (untitled) / with headers
text/plain 910b
On Sun, Aug 20, 2006 at 06:41:48AM -0400, evdb@ecclestoad.co.uk via RT wrote: Show quoted text
> Sorry that it is causing trouble : )
Well, the original problem still needs fixed, so I wouldn't worry too much! :) Show quoted text
> Once i made the changes that I suggested it worked for me - but I > probably didn't exercise the code as thoroughly as you are. If there > is anything that I can do to help please let me know.
Well, if you fancy trying some debugging, just apply the patch and run the existing test suite and see if you can spot why those two tests are now issuing warnings. Each are warning that an object is going out of scope with unsaved changes, so there's something very fishy going on. I suspect this is a sign of a deeper problem somewhere that would bite people hard if we left it in. But I can't see at a glance what it is, and I need to leave now. Otherwise I'll try to have a deeper look tomorrow. Thanks, Tony
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-12366-1156072455-345.17805-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Charset: utf8
References: <RT-Ticket-17805 [...] rt.cpan.org> <rt-3.6.HEAD-12366-1156063796-810.17805-6-0 [...] rt.cpan.org> <f0145aa60608200341uebfaa12i39dc81d725381a08 [...] mail.gmail.com> <rt-3.6.HEAD-12366-1156070507-919.17805-5-0 [...] rt.cpan.org> <20060820111236.GA16934 [...] soto.kasei.com> <rt-3.6.HEAD-12366-1156072455-345.17805-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-4889-1200844894-853.17805-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1200844895-4889-2"
From: roman.daniel [...] gtsnovera.cz
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1754
Download (untitled) / with headers
text/plain 1.7k
As far as I can tell, the bug is still present (3.0.17). It occurs whenever create is called without primary key set - i.e. primary key is either autoincrement column or comes from sequence. I attach simple test reproducing the bug on SQLite database. I don't have a deep understanding of CDBI code structure but by looking at: sub _insert { my ($proto, $data) = @_; my $class = ref $proto || $proto; my $self = $class->_init($data); $self->call_trigger('before_create'); $self->call_trigger('deflate_for_create'); $self->_prepopulate_id if $self->_undefined_primary; ... } I think that after id is prepopulated, the Live_Objects cache is not updated - only access to the cache is within _init call. On Sun Aug 20 07:14:15 2006, tony@kasei.com wrote: Show quoted text
> On Sun, Aug 20, 2006 at 06:41:48AM -0400, evdb@ecclestoad.co.uk via RT > wrote:
> > Sorry that it is causing trouble : )
> > Well, the original problem still needs fixed, so I wouldn't worry too > much! :) >
> > Once i made the changes that I suggested it worked for me - but I > > probably didn't exercise the code as thoroughly as you are. If there > > is anything that I can do to help please let me know.
> > Well, if you fancy trying some debugging, just apply the patch and run > the existing test suite and see if you can spot why those two tests > are > now issuing warnings. Each are warning that an object is going out of > scope with unsaved changes, so there's something very fishy going on. > I > suspect this is a sign of a deeper problem somewhere that would bite > people hard if we left it in. But I can't see at a glance what it is, > and I need to leave now. > > Otherwise I'll try to have a deeper look tomorrow. > > Thanks, > > Tony
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: multipart/mixed; boundary="----------=_1200844894-4889-1"
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: application/octet-stream; name="cdbi_create_test.pl"
Content-Disposition: inline; filename="cdbi_create_test.pl"
Content-Transfer-Encoding: base64
Content-Length: 1126
use strict; use File::Temp; use DBI; use Scalar::Util qw(refaddr); use Test::More 'tests' => 2; my $db_fh = File::Temp->new; my $dbfile = $db_fh->filename; my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", '', '', { 'RaiseError' => 1 } ); $dbh->do(<<"END_CREATE_TABLE"); create table simplest ( id integer primary key autoincrement, other_column integer ); END_CREATE_TABLE { package Simplest; use base qw(Class::DBI); __PACKAGE__->table('simplest'); __PACKAGE__->columns( 'Primary' => qw(id) ); __PACKAGE__->columns( 'Essential' => qw(other_column) ); sub db_Main { return $dbh } } my $r_created = Simplest->create( { 'other_column' => 208 } ); my $r_retrieved1 = Simplest->retrieve( $r_created->id ); my $r_retrieved2 = Simplest->retrieve( $r_created->id ); cmp_ok( refaddr($r_created), '==', refaddr($r_retrieved1), 'Retrieve returns created object' ); cmp_ok( refaddr($r_retrieved1), '==', refaddr($r_retrieved2), 'Retrieved objects are same' ); # vim: expandtab:shiftwidth=4:tabstop=4:softtabstop=0:textwidth=78: ~ ~


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.