[Catalyst] DBIx::Class method, "update_or_create_related" - it tries to populate the primary key value of the related object

kakimoto at tpg.com.au kakimoto at tpg.com.au
Mon Aug 18 13:56:33 BST 2008


hello, all,

 I am trying to use DBIx::Class method, "update_or_create_related" to
cut down the amount of code I have. My code has happily worked with

1) me manually doing a search (with "find") to see if an object in
question exists or not. If it doesn't, I will issue a "new"/"create" .
Else, the "find" will give out the object, I perform whatever I need to
perform on the attributes and update it.

2) the database table of the related object has a nice sequence set up
for its primary key, "ID".

Now, when I tried to use "update_or_create_related", the code actually
produces an error for which the "ID" attribute in the SQL for INSERT is
null and hence, cannot be inserted to the database engine for reason
that a primary key attribute value can never be NULL.

 It's fair up there but I just do not know why is DBIX::Class even
bothering to put the primary key value, ID into the dynamic SQL that it
uses to insert the entry into the database when there's already a
sequence declared for it....





Help!!


K. akimoto
 - it tries to populate the primary key value of the related object



More information about the Catalyst mailing list