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)
1  2 
includes/db/ORMRow.php

diff --combined includes/db/ORMRow.php
@@@ -31,7 -31,7 +31,7 @@@
   * @author Jeroen De Dauw < jeroendedauw@gmail.com >
   */
  
 -abstract class ORMRow implements IORMRow {
 +class ORMRow implements IORMRow {
  
        /**
         * The fields of the object.
         *
         * @since 1.20
         *
 -       * @param $name string: Field name
 +       * @param string $name Field name
         * @param $default mixed: Default value to return when none is found
         * (default: null)
         *
                        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;
                                        $value = (float)$value;
                                        break;
                                case 'bool':
 -                                      if ( is_string( $value ) ) {
 -                                              $value = $value !== '0';
 -                                      } elseif ( is_int( $value ) ) {
 -                                              $value = $value !== 0;
 -                                      }
 +                                      $value = (bool)$value;
                                        break;
                                case 'array':
                                        if ( is_string( $value ) ) {