From 04b3661f520ea3b487d98d9e5caf153f8d307077 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Tue, 10 Oct 2006 20:27:43 +0000 Subject: [PATCH] sync: insert if the primary key (usually an auto-incrementing serial identifier) has not been specified, or the primary key is the only field in the table. --- PLC/Table.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PLC/Table.py b/PLC/Table.py index 1300cf14..be126a65 100644 --- a/PLC/Table.py +++ b/PLC/Table.py @@ -59,7 +59,10 @@ class Row(dict): keys = fields.keys() values = [self.api.db.param(key, value) for (key, value) in fields.items()] - if not self.has_key(self.primary_key): + # If the primary key (usually an auto-incrementing serial + # identifier) has not been specified, or the primary key is the + # only field in the table. + if not self.has_key(self.primary_key) or all_fields == [self.primary_key]: # Insert new row sql = "INSERT INTO %s (%s) VALUES (%s);" % \ (self.table_name, ", ".join(keys), ", ".join(values)) -- 2.47.0