Commit 79d4fd2
authored
Nullable support for __set.
I wrote it and works like a charm. Slightly more efficient, because I some of array_key_exists don't exist anymore ;).
But... I noticed an issue when I am trying to save this entity. Property which is set to null is excluded from INSERT what should cause problem if default column value is not set to null but different value - in that case we cannot save null during insert.
In my case should be:
```
INSERT INTO `t_table_search` (`dcs_identifier`, `dcs_conditions`, `dcs_dsc_id`) VALUES ('e77d630b7be1484cb4b7b4f8dbc15c45', '{\"v-school\":[\"1\"],\"v-center\":[\"44\"]}', NULL) // dcs_dsc_id = null;
```
it is:
```
INSERT INTO `t_table_search` (`dcs_identifier`, `dcs_conditions`) VALUES ('e77d630b7be1484cb4b7b4f8dbc15c45', '{\"v-school\":[\"1\"],\"v-center\":[\"44\"]}')// no null for dcs_dsc_id
```
I think it is because of entity value of property in _original is the same as actual value of property (i.e.: dcs_dsc_id == null)
```object(App\Entities\entityname)#40 (7) {
["dcs_identifier":protected]=>
string(32) "e77d630b7be1484cb4b7b4f8dbc15c45"
["dcs_conditions":protected]=>
string(52) "{"driving-school":["1"],"examination-center":["44"]}"
["dcs_dsc_id":protected]=>
NULL
["dcs_updated_at":protected]=>
NULL
["_options":protected]=>
array(3) {
["casts"]=>
array(3) {
["dcs_identifier"]=>
string(6) "string"
["dcs_conditions"]=>
string(10) "json-array"
["dcs_dsc_id"]=>
string(11) "?json-array"
}
["dates"]=>
array(2) {
[0]=>
NULL
[1]=>
string(14) "dcs_updated_at"
}
["datamap"]=>
array(0) {
}
}
["_original":protected]=>
array(4) {
["dcs_identifier"]=>
NULL
["dcs_conditions"]=>
NULL
["dcs_dsc_id"]=>
NULL
["dcs_updated_at"]=>
NULL
}
["_cast":"CodeIgniter\Entity":private]=>
bool(true)```
I saw PR month or two ago which was changing entity saving but IMHO it should be turned ON for update or replace but should NOT work for INSERT.1 parent 3a4ade9 commit 79d4fd2
1 file changed
Lines changed: 25 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
| 276 | + | |
276 | 277 | | |
277 | 278 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 279 | + | |
282 | 280 | | |
283 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
284 | 297 | | |
285 | 298 | | |
286 | 299 | | |
287 | 300 | | |
| 301 | + | |
288 | 302 | | |
289 | 303 | | |
290 | 304 | | |
| |||
304 | 318 | | |
305 | 319 | | |
306 | 320 | | |
| 321 | + | |
307 | 322 | | |
308 | 323 | | |
309 | 324 | | |
| |||
0 commit comments