cleanup last insert id handling
[dbsrgits/DBIx-Data-Store-old.git] / lib / DBIx / Data / Store / Command / Insert / LastInsertId.pm
CommitLineData
3a2e7c1c 1package DBIx::Data::Store::Command::Insert::LastInsertId;
2
3use Moose;
4use Method::Signatures::Simple;
5
6has 'id_column' => (is => 'ro', required => 1);
7
8has 'insert_call_command' => (is => 'ro', required => 1);
9
de9534fa 10has '_last_insert_id_command' => (is => 'ro', lazy_build => 1);
11
3a2e7c1c 12has 'raw_store' => (is => 'ro', required => 1);
13
de9534fa 14method _build__last_insert_id_command {
15 $self->raw_store->new_closure_command(sub {
16 +{ $self->id_column => shift->last_insert_id((undef) x 4) }
17 });
18}
19
3a2e7c1c 20method execute {
21 $self->insert_call_command->execute;
de9534fa 22 return $self->_last_insert_id_command->execute;
3a2e7c1c 23};
24
3a2e7c1c 25__PACKAGE__->meta->make_immutable;
26
271;