X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FCDBICompat%2FLazyLoading.pm;fp=lib%2FDBIx%2FClass%2FCDBICompat%2FLazyLoading.pm;h=add9390af0d0a5ce66d55f14bc1c7b7c536be87e;hb=e60dc79fcd4d6318e83584b826526e65048b86a9;hp=b7d3633219be41f6584e0093f919363d4a31bffb;hpb=05e8dc0a4848cd094c2aa063d183500017421fcc;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/CDBICompat/LazyLoading.pm b/lib/DBIx/Class/CDBICompat/LazyLoading.pm index b7d3633..add9390 100644 --- a/lib/DBIx/Class/CDBICompat/LazyLoading.pm +++ b/lib/DBIx/Class/CDBICompat/LazyLoading.pm @@ -22,6 +22,28 @@ sub get_column { $self->next::method(@_[1..$#_]); } +# CDBI does not explicitly declare auto increment columns, so +# we just clear out our primary columns before copying. +sub copy { + my($self, $changes) = @_; + + for my $col ($self->primary_columns) { + $changes->{$col} = undef unless exists $changes->{$col}; + } + + return $self->next::method($changes); +} + +sub discard_changes { + my($self) = shift; + + delete $self->{_column_data}{$_} for $self->is_changed; + delete $self->{_dirty_columns}; + delete $self->{_relationship_data}; + + return $self; +} + sub _ident_cond { my ($class) = @_; return join(" AND ", map { "$_ = ?" } $class->primary_columns);