Commit | Line | Data |
3a2e7c1c |
1 | package DBIx::Data::Store::Command::Insert::LastInsertId; |
2 | |
3 | use Moose; |
4 | use Method::Signatures::Simple; |
5 | |
6 | has 'id_column' => (is => 'ro', required => 1); |
7 | |
8 | has 'insert_call_command' => (is => 'ro', required => 1); |
9 | |
de9534fa |
10 | has '_last_insert_id_command' => (is => 'ro', lazy_build => 1); |
11 | |
3a2e7c1c |
12 | has 'raw_store' => (is => 'ro', required => 1); |
13 | |
de9534fa |
14 | method _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 |
20 | method 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 | |
27 | 1; |