[Dbix-class] Question/Issue with bulk create

John Napiorkowski jjn1056 at yahoo.com
Tue Jun 12 00:01:58 GMT 2007


Hi,

I'm trying to use bulk create from the -current branch
on some tables in my postgresql database.  Now I
worked on part of this for the "populate" side of it
but I'm getting weirdness with postgresql.  I'm not
sure if it's just my usage and or expectation.  So I'm
hoping for some pointers for working this out.

I have two tables that are related.  There is
"Resource" and "Event".  Event belongs to Resource,
and Resource might_have an event.  These relationships
are defined in the normal way in my code and seem to
work in all the normal ways.

Now Resource has a resource_id which is autogenerated
and is the primary key.  Event has a PK for
resource_id as well, but since it's a one to one
relationship it's PK is FK to Resource.

Basically my tables are like:

CREATE TABLE Resource(
   resource_id serial,
   .....
   Primary Key (resource_id)
);

CREATE TABLE Event(
  resource_id bigint
  .....
  Primary Key (resource_id),
  Foreign Key (resource_id) references
Resource(resource_id)
)

Now when I try to do something like:

my $Resource ->$schema->resultset('Resource');

my $rs =
$Resource->create({field=>'aaa',event=>{field=>'bbb'}});

I get an error complaining that resource_id is null.

Now I am trying to figure out how bulk create is doing
this magic.  It looks to me like it's trying to create
the Event first and then the resource.  But since I
have fairly tight constraints on the postgresql
database I can't do it this way.

Can anyone enlighten me?  I'm happy to keep hacking at
this and have some ideas for improving some this
function for after the next release but could use a
little guidance.

Thanks!

--John

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Dbix-class mailing list