Commit 6210a606 authored by zYne's avatar zYne

Fixed a bug when saving a record with null valued boolean column

parent ba737729
...@@ -863,6 +863,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -863,6 +863,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach($array as $k => $v) { foreach($array as $k => $v) {
$type = $this->table->getTypeOf($v); $type = $this->table->getTypeOf($v);
if($this->data[$v] === self::$null) {
$a[$v] = null;
continue;
}
switch($type) { switch($type) {
case 'array': case 'array':
case 'object': case 'object':
...@@ -881,10 +886,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -881,10 +886,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if($this->data[$v] instanceof Doctrine_Record) if($this->data[$v] instanceof Doctrine_Record)
$this->data[$v] = $this->data[$v]->getIncremented(); $this->data[$v] = $this->data[$v]->getIncremented();
if($this->data[$v] === self::$null)
$a[$v] = null;
else
$a[$v] = $this->data[$v]; $a[$v] = $this->data[$v];
} }
} }
......
...@@ -6,28 +6,6 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase { ...@@ -6,28 +6,6 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase {
parent::prepareTables(); parent::prepareTables();
} }
public function testSetNull() {
$test = new BooleanTest();
$this->is_working = null;
$this->assertEqual($this->is_working, null);
$this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY);
$test->save();
$test->refresh();
$this->assertEqual($test->is_working, null);
$test = new BooleanTest();
$this->is_working_notnull = null;
$this->assertEqual($this->is_working_notnull, false);
$this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY);
$test->save();
$test->refresh();
$this->assertEqual($test->is_working_notnull, false);
}
public function testSetFalse() { public function testSetFalse() {
$test = new BooleanTest(); $test = new BooleanTest();
$test->is_working = false; $test->is_working = false;
...@@ -84,5 +62,27 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase { ...@@ -84,5 +62,27 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase {
$this->assertEqual(count($ret), 1); $this->assertEqual(count($ret), 1);
} }
public function testSavingNullValue() {
$test = new BooleanTest();
$this->is_working = null;
$this->assertEqual($this->is_working, null);
$this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY);
$test->save();
$test->refresh();
$this->assertEqual($test->is_working, null);
$test = new BooleanTest();
$this->is_working_notnull = null;
$this->assertEqual($this->is_working_notnull, false);
$this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY);
$test->save();
$test->refresh();
$this->assertEqual($test->is_working_notnull, false);
}
} }
?> ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment