From: Tim Landscheidt Date: Fri, 28 Dec 2012 04:56:49 +0000 (+0000) Subject: Fix ORMRow::insert() on PostgreSQL. X-Git-Tag: 1.31.0-rc.0~20379^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=ad4ffa3fd59f40457464756c42adea7e245a14b5;p=lhc%2Fweb%2Fwiklou.git Fix ORMRow::insert() on PostgreSQL. When inserting a new row, ORMRow explicitly passed NULL as the value for the id field which in MySQL means "use next value in sequence", but in PostgreSQL means "use NULL". With this change, for id fields no value is passed if it isn't set to non-null. This fixes bug #43475. This effectively bars the possibility to set the id field of an existing row to NULL, but the current code already disallows any changes in id fields. Change-Id: I29d86fa6fc38ff1852821658e4927b4d7d4a72b6 --- diff --git a/includes/db/ORMRow.php b/includes/db/ORMRow.php index 5c730fb314..5fd99af43d 100644 --- a/includes/db/ORMRow.php +++ b/includes/db/ORMRow.php @@ -261,6 +261,11 @@ abstract class ORMRow implements IORMRow { if ( array_key_exists( $name, $this->fields ) ) { $value = $this->fields[$name]; + // Skip null id fields so that the DBMS can set the default. + if ( $name === 'id' && is_null ( $value ) ) { + continue; + } + switch ( $type ) { case 'array': $value = (array)$value;