Merge "Fix ORMRow::insert() on PostgreSQL."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 12 Mar 2013 11:59:29 +0000 (11:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 12 Mar 2013 11:59:29 +0000 (11:59 +0000)
includes/db/ORMRow.php

index 7fb7ae1..6c1f27f 100644 (file)
@@ -261,6 +261,11 @@ 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;