[Dbix-class] patch for PK::Auto::Oracle
Hartmaier Alexander
Alexander.Hartmaier at t-systems.at
Wed Dec 14 14:25:05 CET 2005
First: BAD ANDYG!!!
sequence.currval instead of sequence.nextval
the rest are docs and better testcase to clear things up.
svn diff
Index: t/run/13oracle.tl
===================================================================
--- t/run/13oracle.tl (revision 390)
+++ t/run/13oracle.tl (working copy)
@@ -36,7 +36,7 @@
# 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) {
Index: lib/DBIx/Class/PK/Auto.pm
===================================================================
--- lib/DBIx/Class/PK/Auto.pm (revision 390)
+++ lib/DBIx/Class/PK/Auto.pm (working copy)
@@ -19,6 +19,11 @@
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
Index: lib/DBIx/Class/PK/Auto/Oracle.pm
===================================================================
--- lib/DBIx/Class/PK/Auto/Oracle.pm (revision 390)
+++ lib/DBIx/Class/PK/Auto/Oracle.pm (working copy)
@@ -10,7 +10,7 @@
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;
}
-Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5544 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20051214/6c98c1ac/smime.bin
More information about the Dbix-class
mailing list