skeleton insert code
[dbsrgits/DBIx-Data-Store-old.git] / lib / DBIx / Data / Store / CRUD.pm
index 5ba2e89..eff5e58 100644 (file)
@@ -10,6 +10,8 @@ foreach my $type (qw(select insert update delete)) {
   has "${type}_argument_order" => (is => 'ro', default => sub { [] });
 }
 
+has 'insert_command_constructor' => (is => 'ro');
+
 has "select_column_order" => (is => 'ro');
 
 method new_select_command ($args) {
@@ -25,17 +27,27 @@ method _unwrap_args_for ($type, $args) {
   [ @{$args}{@{$self->${\"${type}_argument_order"}}} ]
 }
 
-method _new_call_command ($type, $args) {
+method _new_command ($builder, $type, $args) {
   my $has_meth = "has_${type}_sql";
   die "${self}->${has_meth}" unless $self->$has_meth;
-  $self->raw_store->new_call_command(
+  $self->$builder(
     $self->${\"${type}_sql"},
-    $self->_unwrap_args_for($type => $args)
+    $self->_unwrap_args_for($type => $args),
+  );
+}
+
+method _new_call_command ($type, $args) {
+  $self->_new_command(
+    sub { shift->raw_store->new_call_command(@_) },
+    $type => $args,
   );
 }
 
 method new_insert_command ($args) {
-  $self->_new_call_command(insert => $args);
+  my $builder = $self->insert_command_constructor;
+  $builder
+    ? $self->_new_command($builder => insert => $args)
+    : $self->_new_call_command(insert => $args);
 }
 
 method new_update_command ($args) {