- Fix set_column on non-native (+columns) selections (RT#86685)
- Fix set_inflated_column incorrectly handling \[] literals (GH#44)
- Ensure that setting a column to a literal invariably marks it dirty
+ - Fix copy() not working correctly with extra selections present
- Work around exception objects with broken string overloading in one
additional codepath (missed in 0.08260)
- Fix more inconsistencies of the quote_names attribute propagating
sub copy {
my ($self, $changes) = @_;
$changes ||= {};
- my $col_data = { %{$self->{_column_data}} };
+ my $col_data = { $self->get_columns };
my $rsrc = $self->result_source;
- my $colinfo = $rsrc->columns_info([ keys %$col_data ]);
+ my $colinfo = $rsrc->columns_info;
foreach my $col (keys %$col_data) {
delete $col_data->{$col}
- if $colinfo->{$col}{is_auto_increment};
+ if ( ! $colinfo->{$col} or $colinfo->{$col}{is_auto_increment} );
}
my $new = { _column_data => $col_data };
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+my $cd = $schema->resultset('CD')->search({}, {
+ '+columns' => { avg_year => $schema->resultset('CD')->get_column('year')->func_rs('avg')->as_query },
+ order_by => 'cdid',
+})->next;
+
+my $ccd = $cd->copy({ cdid => 5_000_000, artist => 2 });
+
+cmp_ok(
+ $ccd->id,
+ '!=',
+ $cd->id,
+ 'IDs differ'
+);
+
+is(
+ $ccd->title,
+ $cd->title,
+ 'Title same on copied object',
+);
+
+done_testing;