Changeset 3769

Show
Ignore:
Timestamp:
02/14/08 12:49:20 (17 months ago)
Author:
adrive
Message:

convertBoolean method was not working correctly for Pgsql, when integer value 0|1 was used as value for boolean type columns instead of true|false. (e.g. sfGuardDoctrinePlugin will use it in schema.yml)

Added boolean columns to Export/PgsqlTestCase.php to check default attributes for columns.

Location:
branches/0.9
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/lib/Doctrine/Connection/Pgsql.php

    r2963 r3769  
    107107        if (is_array($item)) { 
    108108            foreach ($item as $key => $value) { 
    109                 if (is_bool($value)) { 
     109                if (is_bool($value) || is_numeric($item)) { 
    110110                    $item[$key] = ($value) ? 'true' : 'false'; 
    111111                } 
    112112            } 
    113113        } else { 
    114            if (is_bool($item)) { 
     114           if (is_bool($item) || is_numeric($item)) { 
    115115               $item = ($item) ? 'true' : 'false'; 
    116116           } 
  • branches/0.9/lib/Doctrine/Export.php

    r3131 r3769  
    744744 
    745745            if ($field['type'] === 'boolean') { 
    746                 $fields['default'] = $this->conn->convertBooleans($field['default']); 
     746                $field['default'] = $this->conn->convertBooleans($field['default']); 
    747747            } 
    748748            $default = ' DEFAULT ' . $this->conn->quote($field['default'], $field['type']); 
  • branches/0.9/tests/Export/PgsqlTestCase.php

    r2675 r3769  
    105105        $name = 'mytable'; 
    106106        $fields  = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'), 
    107                          'type' => array('type' => 'integer', 'length' => 3, 'default' => 12) 
     107                         'type' => array('type' => 'integer', 'length' => 3, 'default' => 12), 
     108                         'is_active' => array('type' => 'boolean', 'default'=>'0'), 
     109                         'is_admin'  => array('type' => 'boolean', 'default'=>'true'), 
    108110                         ); 
    109111                          
     
    111113        $this->export->createTable($name, $fields, $options); 
    112114 
    113         $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type INT DEFAULT 12, PRIMARY KEY(name, type))'); 
     115        $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type INT DEFAULT 12, is_active BOOLEAN DEFAULT false, is_admin BOOLEAN DEFAULT true, PRIMARY KEY(name, type))'); 
    114116    } 
    115117    public function testCreateTableSupportsMultiplePks()