[Dbix-class] (svn trunk version) Recursive insert and backward compatibility

Zbigniew Lukasiak zzbbyy at gmail.com
Sun Nov 16 21:43:16 GMT 2008


On Sun, Nov 16, 2008 at 11:51 AM, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> On Sat, Nov 15, 2008 at 9:12 PM, Matt S Trout <dbix-class at trout.me.uk> wrote:
>> On Fri, Nov 07, 2008 at 09:51:45AM +0100, Zbigniew Lukasiak wrote:
>>> I know this is again not very usual setup - but I provide this info -
>>> so that you can make an informed decision about how much
>>> back-compatibillity you are going to support for the next version of
>>> DBIC.   In the past insert worked only on the record passed to it -
>>> now it recurses to related records. This fixes some multi-create
>>> scenarios - but might be sometimes unexpected.
>>
>> I see. A suitable failing test patch would be appreciated; we should
>> easily be able to modify multi-create to only cascade insert for things
>> passed to new()
>
> In the attached no_recursive_insert.diff you'll find the failing test.
>  For it to pass in the current CPAN release you need to uncomment the
> line marked with "For exact backward compatibility" -  in the svn
> version this additional line would do nothing ( and this is OK IMHO).
>
> I am also attaching a tentative patch to insert in DBIx::Class::Row
> and create in DBIx::Class::ResultSet in no_recursive_insert_Row.diff.
> It is just a proposal.

One addition for those too lazy to run the test:

zby at zby:~/progs/DBIC$ prove -Ilib t/66relationship.t
t/66relationship......1/72
#   Failed test 'Reversed staged insertion successful'
#   at t/66relationship.t line 273.
#          got: 'DBIx::Class::Row::insert(): DBI Exception:
DBD::SQLite::st execute failed: cd.title may not be NULL(19) at
dbdimp.c line 403 [for Statement "INSERT INTO cd (artist, cdid,
genreid, title, year) VALUES (?, ?, ?, ?, ?)"] at t/66relationship.t
line 267
# '
#     expected: ''

#   Failed test 'related artist inserted'
#   at t/66relationship.t line 274.

#   Failed test 'cd inserted'
#   at t/66relationship.t line 275.
# Looks like you failed 3 tests of 72.
t/66relationship...... Dubious, test returned 3 (wstat 768, 0x300)
 Failed 3/72 subtests



-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/



More information about the DBIx-Class mailing list