Skip to content

Commit da833c5

Browse files
authored
Fix false defaults (#75)
1 parent eec8400 commit da833c5

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/Ql/Cql/CqlDataStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ protected function _assemble(IStatement $statement, $forPrepare = true)
117117

118118
protected function _getInsertData(QlDao $dao)
119119
{
120-
$initial = $dao->isDaoLoaded() ? [] : array_filter($dao->getDefaultDaoValues());
121-
$changes = array_merge($initial, $this->_getDaoChanges($dao));
120+
$init = $dao->isDaoLoaded() ? [] : array_filter($dao->getDefaultDaoValues(), function ($v) { return $v !== null; });
121+
$changes = array_merge($init, $this->_getDaoChanges($dao));
122122
foreach($dao->getDaoIDProperties() as $prop)
123123
{
124124
if(!isset($changes[$prop]))

tests/Ql/Cql/CqlTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ public function testAlwaysInsertIDWithPrefil()
535535
[
536536
[
537537
'runQuery',
538-
'INSERT INTO "mock_ql_daos" ("intVal", "id", "id2", "username") VALUES (?, ?, ?, ?)',
539-
[1, $dao->id, 12345, 'abc'],
538+
'INSERT INTO "mock_ql_daos" ("intVal", "boolVal", "id", "id2", "username") VALUES (?, ?, ?, ?, ?)',
539+
[1, false, $dao->id, 12345, 'abc'],
540540
],
541541
],
542542
$connection->getQueries()

tests/Ql/Cql/Mocks/MockPrefillCqlDao.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
class MockPrefillCqlDao extends MockCqlDao
55
{
66
public $intVal = 1;
7+
public $boolVal = false;
78
}

0 commit comments

Comments
 (0)