From: Daniel Westermann-Clark Date: Wed, 10 May 2006 17:00:11 +0000 (-0400) Subject: Merge 'trunk' into 'DBIx-Class-current' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ce17c23e187344566fdeabf9362f61567ca7c955;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'trunk' into 'DBIx-Class-current' r8956@fortuna (orig r1603): dwc | 2006-05-10 12:00:11 -0400 Row::update encapsulates this when passed a hashref; using set_columns bypasses deflation --- ce17c23e187344566fdeabf9362f61567ca7c955 diff --cc Changes index bf29764,c5716e7..e94364d --- a/Changes +++ b/Changes @@@ -1,22 -1,8 +1,24 @@@ Revision history for DBIx::Class + - modified SQLT parser to skip dupe table names + - added remove_column(s) to ResultSource/ResultSourceProxy + - added add_column alias to ResultSourceProxy + - added source_name to ResultSource + - load_classes now uses source_name and sets it if necessary + - add update_or_create_related to Relationship::Base + - add find_or_new to ResultSet/ResultSetProxy and find_or_new_related + to Relationship::Base + - add accessors for unique constraint names and coulums to + ResultSource/ResultSourceProxy + - rework ResultSet::find() to search unique constraints + - CDBICompat: modify retrieve to fix column casing when ColumnCase is + loaded + - CDBICompat: override find_or_create to fix column casing when + ColumnCase is loaded + 0.06003 + - don't set_columns explicitly in update_or_create; instead use + update($hashref) so InflateColumn works - fix for has_many prefetch with 0 related rows - make limit error if rows => 0 - added memory cycle tests and a long-needed weaken call diff --cc lib/DBIx/Class/ResultSet.pm index 7d18853,3efbf00..db58023 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@@ -1257,11 -1139,29 +1257,10 @@@ sub update_or_create my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}); my $hash = ref $_[0] eq 'HASH' ? shift : {@_}; - my %unique_constraints = $self->result_source->unique_constraints; - my @constraint_names = (exists $attrs->{key} - ? ($attrs->{key}) - : keys %unique_constraints); - - my @unique_hashes; - foreach my $name (@constraint_names) { - my @unique_cols = @{ $unique_constraints{$name} }; - my %unique_hash = - map { $_ => $hash->{$_} } - grep { exists $hash->{$_} } - @unique_cols; - - push @unique_hashes, \%unique_hash - if (scalar keys %unique_hash == scalar @unique_cols); - } - - if (@unique_hashes) { - my $row = $self->single(\@unique_hashes); - if (defined $row) { - $row->update($hash); - return $row; - } + my $row = $self->find($hash, $attrs); + if (defined $row) { - $row->set_columns($hash); - $row->update; ++ $row->update($hash); + return $row; } return $self->create($hash);