From: Jess Robinson Date: Wed, 14 Dec 2005 14:22:23 +0000 (+0000) Subject: Patches from Andreas Hartmeier applied to PK::Auto X-Git-Tag: v0.05005~133 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c8f4b52ba7e5e8a2e5a91655bfc058a54155dcc5;p=dbsrgits%2FDBIx-Class.git Patches from Andreas Hartmeier applied to PK::Auto --- diff --git a/lib/DBIx/Class/PK/Auto.pm b/lib/DBIx/Class/PK/Auto.pm index ce745aa..d6dd3a5 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -19,6 +19,11 @@ incremented primary keys. You don't want to be using this directly - instead load the appropriate one for your database, e.g. PK::Auto::SQLite +=head1 LOGIC + +PK::Auto does this by letting the database assign the primary key field +and fetching the assigned value afterwards. + =head1 METHODS =head2 insert diff --git a/lib/DBIx/Class/PK/Auto/Oracle.pm b/lib/DBIx/Class/PK/Auto/Oracle.pm index 1186b1a..814496e 100644 --- a/lib/DBIx/Class/PK/Auto/Oracle.pm +++ b/lib/DBIx/Class/PK/Auto/Oracle.pm @@ -10,7 +10,7 @@ __PACKAGE__->load_components(qw/PK::Auto/); sub last_insert_id { my $self = shift; $self->get_autoinc_seq unless $self->{_autoinc_seq}; - my $sql = "SELECT " . $self->{_autoinc_seq} . ".nextval FROM DUAL"; + my $sql = "SELECT " . $self->{_autoinc_seq} . ".currval FROM DUAL"; my ($id) = $self->storage->dbh->selectrow_array($sql); return $id; } diff --git a/t/run/13oracle.tl b/t/run/13oracle.tl index a5ab861..d524b96 100644 --- a/t/run/13oracle.tl +++ b/t/run/13oracle.tl @@ -36,7 +36,7 @@ OraTest::Artist->load_components('PK::Auto::Oracle'); # test primary key handling my $new = OraTest::Artist->create({ name => 'foo' }); -ok($new->artistid, "Oracle Auto-PK worked"); +is($new->artistid, 1, "Oracle Auto-PK worked"); # test LIMIT support for (1..6) {