Pass to `ColumnInterface::dbTypecast()` non-null and non-expression values only
Seems, all implementations of ColumnInterface::dbTypecast() checks value on null and ExpressionInterface and return it as is for those values:
if ($value === null || $value instanceof ExpressionInterface) {
return $value;
}
We can check it before call dbTypecast() and simplify simplify both existing implementations and the creation of custom ones.
Any ideas how to realize it?
Type casting should be fast, this is one of the bottlenecks of AR. In current realization it is faster then it was before. It's better to first check if the value matches the expected type, and then cast it to the expected type if necessary.
function dbTypecast(ColumnInterface $column, mixed $value): mixed
{
if ($value === null || $value instanceof ExpressionInterface) {
return $value;
}
return $column->dbTypecast($value);
}
And instead of $column->dbTypecast($value) call dbTypecast($column, $value).
What if I need type-casting for null values?
What if I need type-casting for null values?
If such a case exists, then check only ExpressionInterface
First, needs to benchmark the current and new approaches.