Showing 1 changed files with 8 additions and 10 deletions
+8 -10
lib/DBIx/Custom.pm
... ...
@@ -601,16 +601,9 @@ sub insert {
601 601
     my $param = @_ % 2 ? shift : undef;
602 602
     my %args = @_;
603 603
     $param ||= $args{param} || {};
604
-    my $id = $args{id};
605
-    my $primary_key = $args{primary_key};
606
-    croak "insert method primary_key option " .
607
-          "must be specified when id is specified " . _subname
608
-      if defined $id && !defined $primary_key;
609
-    $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY';
610
-    my $timestamp = $args{timestamp};
611 604
     
612 605
     # Timestamp
613
-    if ($timestamp && (my $insert_timestamp = $self->insert_timestamp)) {
606
+    if ($args{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
614 607
         my $columns = $insert_timestamp->[0];
615 608
         $columns = [$columns] unless ref $columns eq 'ARRAY';
616 609
         my $value = $insert_timestamp->[1];
... ...
@@ -619,8 +612,8 @@ sub insert {
619 612
     }
620 613
 
621 614
     # Merge parameter
622
-    if (defined $id) {
623
-        my $id_param = $self->_create_param_from_id($id, $primary_key);
615
+    if (defined $args{id}) {
616
+        my $id_param = $self->_create_param_from_id($args{id}, $args{primary_key});
624 617
         $param = $self->merge_param($id_param, $param);
625 618
     }
626 619
 
... ...
@@ -1331,6 +1324,11 @@ sub _create_bind_values {
1331 1324
 
1332 1325
 sub _create_param_from_id {
1333 1326
     my ($self, $id, $primary_keys, $table) = @_;
1327
+
1328
+    croak "primary_key option " .
1329
+          "must be specified with id option " . _subname
1330
+      unless defined $primary_keys;
1331
+    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
1334 1332
     
1335 1333
     # Create parameter
1336 1334
     my $param = {};