Fix copy() assuming all columns are native
[dbsrgits/DBIx-Class.git] / t / row / copy_with_extra_selection.t
diff --git a/t/row/copy_with_extra_selection.t b/t/row/copy_with_extra_selection.t
new file mode 100644 (file)
index 0000000..c1e3df4
--- /dev/null
@@ -0,0 +1,31 @@
+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;