[freeside-commits] freeside/FS/FS Record.pm,1.108,1.109

Ivan,,, ivan at wavetail.420.am
Wed Dec 7 15:48:59 PST 2005


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv9907/FS/FS

Modified Files:
	Record.pm 
Log Message:
for fetching inserted keys without pg_oid_status, look up the actual sequence name from dbdef rather than assuming ${table}_${column}_seq

Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- Record.pm	6 Dec 2005 22:25:56 -0000	1.108
+++ Record.pm	7 Dec 2005 23:48:57 -0000	1.109
@@ -752,7 +752,16 @@
 
       #my $oid = $sth->{'pg_oid_status'};
       #my $i_sql = "SELECT $primary_key FROM $table WHERE oid = ?";
-      my $i_sql = "SELECT currval('${table}_${primary_key}_seq')";
+
+      my $default = $self->dbdef_table->column($primary_key)->default;
+      unless ( $default =~ /^nextval\('"?([\w\.]+)"?'/i ) {
+        dbh->rollback if $FS::UID::AutoCommit;
+        return "can't parse $table.$primary_key default value".
+               " for sequence name: $default";
+      }
+      my $sequence = $1;
+
+      my $i_sql = "SELECT currval('$sequence')";
       my $i_sth = dbh->prepare($i_sql) or do {
         dbh->rollback if $FS::UID::AutoCommit;
         return dbh->errstr;



More information about the freeside-commits mailing list