Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 2.0.2 under development

- Enh #960: Skip type casting of `null` values in DML query builders and column definition builder —
`null` is now passed through without calling `ColumnInterface::dbTypecast()` (@KalimeroMK)

- Enh #1172: Refactor `Query::queryScalar()` to use a cloned `Query` object (@darkspock)
- New #1178: Support `UnitEnum` enums as column values (@Tigrov)
- Bug #1176: Index the result of `AbstractSchema::getSchemaMetadata()` by table name, so `getSchemaChecks()`,
Expand Down
3 changes: 2 additions & 1 deletion src/QueryBuilder/AbstractColumnDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ protected function buildDefault(ColumnInterface $column): string
return '';
}

$defaultValue = $column->dbTypecast($column->getDefaultValue());
$defaultValue = $column->getDefaultValue();
$defaultValue = $defaultValue === null ? null : $column->dbTypecast($defaultValue);
$defaultValue = $this->queryBuilder->prepareValue($defaultValue);

if ($defaultValue === '') {
Expand Down
6 changes: 3 additions & 3 deletions src/QueryBuilder/AbstractDMLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected function prepareBatchInsertValues(string $table, iterable $rows, array
$columnName = $columnNames[$key] ?? (isset($keys[$key]) ? $key : $names[$i] ?? $i);

if (isset($columns[$columnName])) {
$value = $columns[$columnName]->dbTypecast($value);
$value = $value === null ? null : $columns[$columnName]->dbTypecast($value);
}

$placeholders[$columnName] = $queryBuilder->buildValue($value, $params);
Expand Down Expand Up @@ -377,7 +377,7 @@ protected function prepareInsertValues(string $table, array|QueryInterface $colu

foreach ($columns as $name => $value) {
if (isset($tableColumns[$name])) {
$value = $tableColumns[$name]->dbTypecast($value);
$value = $value === null ? null : $tableColumns[$name]->dbTypecast($value);
}
$placeholders[] = $this->queryBuilder->buildValue($value, $params);
}
Expand Down Expand Up @@ -415,7 +415,7 @@ protected function prepareUpdateSets(

foreach ($columns as $name => $value) {
if (isset($typecastColumns[$name])) {
$value = $typecastColumns[$name]->dbTypecast($value);
$value = $value === null ? null : $typecastColumns[$name]->dbTypecast($value);
}

$quotedName = $quoter->quoteSimpleColumnName($name);
Expand Down
Loading