[CDBI] Bug with sequences and the object cache ( I think )

Edmund von der Burg edmund.vonderburg at gmail.com
Wed Nov 9 17:06:57 GMT 2005


Hello,

I came across some odd behaviour in Class::DBI and have reduced it
down to the attached test script.

It involves sequences - when a primary key is created from a sequence
then the object is not correctly fetched from / stored in  the object
cache which leads to there being two objects in memory at once. My
guess is that the identifier is being looked at differently / maybe a
string/integer thing. I haven't dug into the sources so this is just a
guess.

The test needs a postgres database called 'cdbi_test'. It creates the
tables and sequences that it needs and then clears them out at the
end. As SQLite does not have sequences I did not know how to go about
getting this working with that.

Tested against CDBI version 'v3.0.12'.

Attached - the test script and the output that I get.

Cheers,
  Edmund.

--
In reality I'm evdb at ecclestoad.co.uk - http://ecclestoad.co.uk
-------------- next part --------------
# $Class::DBI::VERSION: 'v3.0.12'
# Creating tables and sequence
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parents_pkey" for table "parents"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "children_pkey" for table "children"
#
# using cdbi_id: 1000000
#
ok 1 - create test parent
ok 2 - create test child
ok 3 - names the same
ok 4 - change name
ok 5 - names the same
ok 6 - update
ok 7 - names the same
ok 8 - dbi_commit
ok 9 - names the same
#
# using cdbi_id: undef
#
ok 10 - create test parent
ok 11 - create test child
ok 12 - names the same
ok 13 - change name
not ok 14 - names the same
#     Failed test (class-dbi-strangeness.t at line 89)
#          got: 'new name'
#     expected: 'test parent'
ok 15 - update
not ok 16 - names the same
#     Failed test (class-dbi-strangeness.t at line 91)
#          got: 'new name'
#     expected: 'test parent'
ok 17 - dbi_commit
not ok 18 - names the same
#     Failed test (class-dbi-strangeness.t at line 94)
#          got: 'new name'
#     expected: 'test parent'
# $VAR1 = {
#           '$parent' => bless( {
#                                 'name' => 'new name',
#                                 'cdbi_id' => '2'
#                               }, 'Parent' ),
#           '$child->parent' => bless( {
#                                        'name' => 'test parent',
#                                        'cdbi_id' => '2'
#                                      }, 'Parent' )
#         };
# Destroying tables and sequence
1..18
# Looks like you failed 3 tests of 18.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class-dbi-strangeness.t
Type: application/x-troff
Size: 3512 bytes
Desc: not available
Url : http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20051109/446dfc09/class-dbi-strangeness.t


More information about the ClassDBI mailing list