Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Model nesting for Array persistence #961

Merged
merged 16 commits into from
Jan 16, 2022
Merged
Prev Previous commit
Next Next commit
fix TestCase::getDb() for "_id" ID
  • Loading branch information
mvorisek committed Jan 15, 2022
commit 0b221eb59df7f234dc5b597ea2d2bae3e3d855ca
9 changes: 7 additions & 2 deletions src/Schema/TestCase.php
Original file line number Diff line number Diff line change
@@ -327,18 +327,23 @@ public function getDb(array $tableNames = null, bool $noId = false): array
$s = $this->db->dsql();
$data = $s->table($table)->getRows();

$idColumnName = null;
foreach ($data as &$row) {
if ($idColumnName === null) {
$idColumnName = isset($row['_id']) ? '_id' : 'id';
}

foreach ($row as &$val) {
if (is_int($val)) {
$val = (int) $val;
}
}

if ($noId) {
unset($row['id']);
unset($row[$idColumnName]);
$data2[] = $row;
} else {
$data2[$row['id']] = $row;
$data2[$row[$idColumnName]] = $row;
}
}