X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FData%2FStore%2FCommand%2FInsert%2FLastInsertId.pm;h=03a8c36e3d022de68f0ab92e44f7af2df8028026;hb=de9534fa36a965cd35e5b212d093dee64e78e8b9;hp=eb9d9046debfec882ea4bbcadb73fa4c97233367;hpb=3a2e7c1c79cf7db2ac812f2e250e939d3e88d639;p=dbsrgits%2FDBIx-Data-Store-old.git diff --git a/lib/DBIx/Data/Store/Command/Insert/LastInsertId.pm b/lib/DBIx/Data/Store/Command/Insert/LastInsertId.pm index eb9d904..03a8c36 100644 --- a/lib/DBIx/Data/Store/Command/Insert/LastInsertId.pm +++ b/lib/DBIx/Data/Store/Command/Insert/LastInsertId.pm @@ -7,21 +7,21 @@ has 'id_column' => (is => 'ro', required => 1); 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;