On Mon, Aug 18, 2008 at 2:56 PM, <[EMAIL PROTECTED]> wrote: > > 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.... >
It's a long story - you might have a look at: http://lists.scsys.co.uk/pipermail/dbix-class/2008-June/thread.html#6403 to see some discussion about it. I also posted some code for a DBIx::Class "plugin" with a modified update_or_create_related method (which should work for you and additionaly it allows for recursive updating the database). It is not really polished code - it requires some name changes - but it has test :) By the way - there is a separate DBIC mailing list (see the link above) where you should direct emails in thit subject. -- Zbigniew Lukasiak http://brudnopis.blogspot.com/ http://perlalchemy.blogspot.com/ _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
