has 'insert_call_command' => (is => 'ro', required => 1);
+has '_last_insert_id_command' => (is => 'ro', lazy_build => 1);
+
has 'raw_store' => (is => 'ro', required => 1);
+method _build__last_insert_id_command {
+ $self->raw_store->new_closure_command(sub {
+ +{ $self->id_column => shift->last_insert_id((undef) x 4) }
+ });
+}
+
method execute {
$self->insert_call_command->execute;
- return { $self->id_column => $self->_get_last_insert_id }
+ return $self->_last_insert_id_command->execute;
};
-method _get_last_insert_id {
- # this should probably involve some sort of call to the raw
- # store to get the command object from it, but meh
- $self->raw_store->connection->run(sub {
- shift->last_insert_id((undef) x 4)
- });
-}
-
__PACKAGE__->meta->make_immutable;
1;