Closed utkant closed 6 years ago
If you cast NULL to Int what do you expect?
If I have a table where id can be NULL or an integer, and I want the result NULL when NULL and not 0 as in integer 0, since 0 can be a valid id, how can I achieve? I need to add code for that. I believe that this is a bug.
NULL (id) !== 0(id) ...
Don't cast then
This means that all fields that have id columns containing NULL values cannot use casting and needs extra processing. I would love it if medoo added a [Id] casting option where this was fixed. Possibility?
Something like this in the mapping switch
case 'Id': $stack[ $column_key ] = is_null($data[ $column_key ]) ? null : (int) $data[ $column_key ]; break;
Yes, this is a bug. The null value should return as Null not 0. I made a bug fix for this. d28ae10
Hello!
I have a select where i cast the ids to Int in the select, but it casts the null value to 0 which is not what I want. Is this a bug or is this supposed to be like this?
$fields = ["id [Int]"]; $this->database->get("table", $fields)
If id is NULL then this gives it the value 0 and not null.