[Dbix-class] Oracle Auto-PK no longer works after upgrade to 0.05xxx and conversion to Schema

James FitzGibbon jfitzgibbon at primustel.ca
Wed Mar 8 21:07:15 CET 2006


I'm not sure what I've managed to do here, but the exercise of upgrading
from 0.04xxx to 0.05007 and converting from DB to Schema has stopped my
Oracle automatic primary keys from working.

I'll start off by saying that I have a strange setup, because I need to
support both Oracle and PostgreSQL using the same set of code.  I load DBIC
components both at compile time and runtime.  My module hierarchy works a
bit like this:

Common bits:

SPE::DBIx::Class:
    - is-a DBIx::Class
    - loads components InflateColumn::DateTime and Core at compile time
SPE::DBIx::Class::Schema
    - is-a DBIx::Class::Schema
    - loads either PK::Auto::Oracle or PK::Auto::Pg at runtime

App-specific bits:

SPE::DCH::Schema
    - is-a SPE::DBIx::Class::Schema
SPE::DCH::Schema::Job
    - is-a SPE::DBIx::Class

There are several table classes, but I've been able to reproduce the problem
with this small setup.

The problem is that when I create a new object, DBIx::Class::Row->insert is
invoked rather than DBIx::Class::PK::Auto->insert.  Here's where it all
starts to go wrong in the debugger:

  DB<2> v
629     sub create {
630:      my ($self, $attrs) = @_;
631:      $self->throw_exception( "create needs a hashref" ) unless ref
$attrs eq 'HASH';
632==>    return $self->new_result($attrs)->insert;
633     }
  DB<3> p ref $self->new_result($attrs)
SPE::DCH::Schema::Job
  DB<4> s
DBIx::Class::ResultSet::new_result(/opt/perl5/lib/site_perl/5.8.7/DBIx/Class
/ResultSet.pm:604):
604:      my ($self, $values) = @_;
  DB<4> n
[...]
DBIx::Class::ResultSet::new_result(/opt/perl5/lib/site_perl/5.8.7/DBIx/Class
/ResultSet.pm:616):
616:      $obj;
  DB<4> n
DBIx::Class::Row::insert(/opt/perl5/lib/site_perl/5.8.7/DBIx/Class/Row.pm:59
):
59:       my ($self) = @_;
  DB<4>

Note that even though SPE::DCH::Schema::Job is a SPE::DBIx::Class, which in
turn loads the oracle auto PK bits, the insert that is called is the
standard one.

I've tried checking the C3 MRO, and I think that insert should be getting
called correctly, since DBIx::Class::PK::Auto comes before DBIx::Class::Row
in the MRO list:

  DB<6> x Class::C3::calculateMRO('SPE::DCH::Schema::Job')
0  'SPE::DCH::Schema::Job'
1  'SPE::DBIx::Class'
2  'DBIx::Class::PK::Auto::Oracle'
3  'DBIx::Class::PK::Auto'
4  'DBIx::Class::InflateColumn::DateTime'
5  'DBIx::Class::Core'
6  'DBIx::Class::InflateColumn'
7  'DBIx::Class::Relationship'
8  'DBIx::Class::Relationship::Helpers'
9  'DBIx::Class::Relationship::HasMany'
10  'DBIx::Class::Relationship::HasOne'
11  'DBIx::Class::Relationship::BelongsTo'
12  'DBIx::Class::Relationship::ManyToMany'
13  'DBIx::Class::Relationship::Accessor'
14  'DBIx::Class::Relationship::CascadeActions'
15  'DBIx::Class::Relationship::ProxyMethods'
16  'DBIx::Class::Relationship::Base'
17  'DBIx::Class::PK'
18  'DBIx::Class::Row'
19  'DBIx::Class::ResultSourceProxy::Table'
20  'DBIx::Class::AccessorGroup'
21  'DBIx::Class::ResultSourceProxy'
22  'DBIx::Class'
23  'DBIx::Class::Componentised'
24  'Class::Data::Accessor'
  DB<7>

Any ideas on how I could further troubleshoot this?  The conversion from DB
to Schema has been fairly painful already, and I'm just about ready to throw
it out and go back to 0.04xxx, which had the same component loading style
but worked properly.

Thanks

-- 
j.
 
James FitzGibbon
Systems Developer, Primus Telecommunications Canada Inc.
416.644.6111

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.2.0/276 - Release Date: 3/7/2006
 



-- 
----------------------------------------------------------------------------
This electronic message contains information from Primus Telecommunications
Canada Inc. ("PRIMUS") , which may be legally privileged and confidential.
The information is intended to be for the use of the individual(s) or entity
named above. If you are not the intended recipient, be aware that any
disclosure, copying, distribution or use of the contents of this information
is prohibited. If you have received this electronic message in error, please
notify us by telephone or e-mail (to the number or address above)
immediately. Any views, opinions or advice expressed in this electronic
message are not necessarily the views, opinions or advice of PRIMUS.
It is the responsibility of the recipient to ensure that
any attachments are virus free and PRIMUS bears no responsibility
for any loss or damage arising in any way from the use
thereof.The term "PRIMUS" includes its affiliates.
----------------------------------------------------------------------------
Pour la version en français de ce message, veuillez voir
 http://www.primustel.ca/fr/legal/cs.htm
----------------------------------------------------------------------------




More information about the Dbix-class mailing list