From 4b4c5e8a84fcfc5375583aac466513a81e7385f7 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 24 Apr 2015 13:50:33 +0000 Subject: [PATCH] * PostgreSQL/Addressbook: fixed not working creating of new distribution lists caused by egw_db::insert() using 0 or NULL in value of $where of primary key when trying to create the list, MySQL ignories these --- phpgwapi/inc/class.egw_db.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index 9353290014..6f5ce42f4f 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -1576,6 +1576,7 @@ class egw_db } elseif (is_int($key) && $use_key===True) { + if (empty($data)) continue; // would give SQL error $values[] = $data; } elseif ($glue != ',' && $use_key === True && !$not_null && is_null($data)) @@ -1789,7 +1790,9 @@ class egw_db // the checked values need to be inserted too, value in data has precedence, also cant insert sql strings (numerical id) foreach($where as $column => $value) { - if (!is_numeric($column) && !isset($data[$column])) + if (!is_numeric($column) && !isset($data[$column]) && + // skip auto-id of 0 or NULL, as PostgreSQL does NOT create an auto-id, if they are given + !(!$value && count($table_def['pk']) == 1 && $column == $table_def['pk'][0])) { $data[$column] = $value; }