[Bast-commits] r3411 - in branches/DBIx-Class-current: .
lib/DBIx/Class
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Tue May 29 02:07:30 GMT 2007
Author: matthewt
Date: 2007-05-29 02:07:30 +0100 (Tue, 29 May 2007)
New Revision: 3411
Modified:
branches/DBIx-Class-current/
branches/DBIx-Class-current/lib/DBIx/Class/Row.pm
Log:
r51585 at cain (orig r3303): castaway | 2007-05-11 14:16:30 +0000
Check rel_in_storage in Row::insert, only insert rel objects when necessary
Property changes on: branches/DBIx-Class-current
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.bulk_create:29204
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.current:29201
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.oracle8:29250
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/bulk_create:3299
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/collapse_result_rewrite:3292
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/column_info_from_storage:2596
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/load_namespaces:2725
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/param_bind:3015
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/source-handle:2975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/storage_exceptions:2617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/versioning:2930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3355
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.bulk_create:29204
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.current:29201
78d5d833-3a7e-474d-aed6-cfba645156b5:/local/DBIx-Class.oracle8:29250
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/bulk_create:3303
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/collapse_result_rewrite:3292
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/column_info_from_storage:2596
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/load_namespaces:2725
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/param_bind:3015
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/source-handle:2975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/storage_exceptions:2617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/versioning:2930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3355
Modified: branches/DBIx-Class-current/lib/DBIx/Class/Row.pm
===================================================================
--- branches/DBIx-Class-current/lib/DBIx/Class/Row.pm 2007-05-29 01:07:25 UTC (rev 3410)
+++ branches/DBIx-Class-current/lib/DBIx/Class/Row.pm 2007-05-29 01:07:30 UTC (rev 3411)
@@ -64,6 +64,7 @@
my ($related,$inflated);
## Pretend all the rels are actual objects, unset below if not, for insert() to fix
$new->{_rel_in_storage} = 1;
+
foreach my $key (keys %$attrs) {
if (ref $attrs->{$key}) {
## Can we extract this lot to use with update(_or .. ) ?
@@ -146,18 +147,21 @@
$source->storage->txn_begin if(!$self->{_rel_in_storage});
# Check if we stored uninserted relobjs here in new()
- $source->storage->txn_begin if(!$self->{_rel_in_storage});
-
my %related_stuff = (%{$self->{_relationship_data} || {}},
%{$self->{_inflated_column} || {}});
- ## Should all be in relationship_data, but we need to get rid of the
- ## 'filter' reltype..
- ## These are the FK rels, need their IDs for the insert.
- foreach my $relname (keys %related_stuff) {
- my $rel_obj = $related_stuff{$relname};
- if(Scalar::Util::blessed($rel_obj) && $rel_obj->isa('DBIx::Class::Row')) {
- $rel_obj->insert();
- $self->set_from_related($relname, $rel_obj);
+ if(!$self->{_rel_in_storage})
+ {
+ $source->storage->txn_begin;
+
+ ## Should all be in relationship_data, but we need to get rid of the
+ ## 'filter' reltype..
+ ## These are the FK rels, need their IDs for the insert.
+ foreach my $relname (keys %related_stuff) {
+ my $rel_obj = $related_stuff{$relname};
+ if(Scalar::Util::blessed($rel_obj) && $rel_obj->isa('DBIx::Class::Row')) {
+ $rel_obj->insert();
+ $self->set_from_related($relname, $rel_obj);
+ }
}
}
@@ -178,20 +182,23 @@
$self->store_column($pri => $id);
}
- ## Now do the has_many rels, that need $selfs ID.
- foreach my $relname (keys %related_stuff) {
- my $relobj = $related_stuff{$relname};
- if(ref $relobj eq 'ARRAY') {
- foreach my $obj (@$relobj) {
- my $info = $self->relationship_info($relname);
- ## What about multi-col FKs ?
- my $key = $1 if($info && (keys %{$info->{cond}})[0] =~ /^foreign\.(\w+)/);
- $obj->set_from_related($key, $self);
- $obj->insert() if(!$obj->in_storage);
+ if(!$self->{_rel_in_storage})
+ {
+ ## Now do the has_many rels, that need $selfs ID.
+ foreach my $relname (keys %related_stuff) {
+ my $relobj = $related_stuff{$relname};
+ if(ref $relobj eq 'ARRAY') {
+ foreach my $obj (@$relobj) {
+ my $info = $self->relationship_info($relname);
+ ## What about multi-col FKs ?
+ my $key = $1 if($info && (keys %{$info->{cond}})[0] =~ /^foreign\.(\w+)/);
+ $obj->set_from_related($key, $self);
+ $obj->insert() if(!$obj->in_storage);
+ }
}
}
+ $source->storage->txn_commit;
}
- $source->storage->txn_commit if(!$self->{_rel_in_storage});
$self->in_storage(1);
$self->{_dirty_columns} = {};
More information about the Bast-commits
mailing list