From: Tony Mack Date: Fri, 10 Oct 2008 18:13:28 +0000 (+0000) Subject: bug fix in Table.sync. Only attempt to fetch/generate next primary key if it isnt... X-Git-Tag: PLCAPI-4.2-14~7 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7a7d6e9811fcb85e38e6431da07c97dd545234e6;p=plcapi.git bug fix in Table.sync. Only attempt to fetch/generate next primary key if it isnt included --- diff --git a/PLC/Table.py b/PLC/Table.py index 74da3e9c..07c3c09d 100644 --- a/PLC/Table.py +++ b/PLC/Table.py @@ -231,8 +231,9 @@ class Row(dict): keys == [self.primary_key] or \ insert is True: - # If primary key id is a serial int, get next id - if self.fields[self.primary_key].type in (IntType, LongType): + # If primary key id is a serial int and it isnt included, get next id + if self.fields[self.primary_key].type in (IntType, LongType) and \ + self.primary_key not in self: pk_id = self.api.db.next_id(self.table_name, self.primary_key) self[self.primary_key] = pk_id db_fields[self.primary_key] = pk_id