[Dbix-class] Oracle Auto-PK no longer works after upgrade to 0.05xxx and conversion to Schema
Christopher H. Laco
claco at chrislaco.com
Wed Mar 8 21:19:01 CET 2006
James FitzGibbon wrote:
> 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
>
I think the good news is, you won't need this hack for much longer right?
SPE::DBIx::Class::Schema
- is-a DBIx::Class::Schema
- loads either PK::Auto::Oracle or PK::Auto::Pg at runtime
I'm pretty sure -current has PK:: autoloading depending on the db you're
using...
Of course, I could be making this all up in my head, which is currently
plugged into the Matrix.
-=Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060308/e62bc35c/attachment-0001.pgp
More information about the Dbix-class
mailing list