You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: DataMapper columns() binds no value for a null value #17817
Describe the bug Phalcon\DataMapper\Query\Insert::columns() and Update::columns() call column() for each pair. column() with a null value adds the token :name and binds no value, because a column() with no value means "bind it later". So columns(['score' => null]) gives a token with no value, where the caller gives the value null.
On MySQL: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens. SQLite accepts it, and gives NULL to a token with no value.
Expected behavior
In the map form of columns() (a string key), a null value is a value: the token is bound to null. The list form (an integer key, only the column name) keeps "bind it later". column($name) with no value keeps "bind it later" too.
This changes what columns() does with null, so it is for 7.0.
Details
Phalcon version: 5.0.x (927c773be7): phalcon/DataMapper/Query/Insert.zep and Update.zep, column() (line 46; the check if null !== value on line 50) and columns() (line 62).
phalcon/phalcon v6.0.x (aeca48611) has the same code: src/DataMapper/Query/Insert.php (column(), line 57) and src/DataMapper/Query/Update.php (column(), line 55).
Additional context
Found in phalcon/crest#84 (make:repository). The repository base of crest calls set($column) (it writes NULL) for a null value, and column() for the other values. Crest keeps that code; this issue is for the next major version.
Activity