Model - Fix zero value primary key#4975
Model - Fix zero value primary key#4975najdanovicivan wants to merge 1 commit intocodeigniter4:developfrom
Conversation
2474ce9 to
ff8e16e
Compare
MGatner
left a comment
There was a problem hiding this comment.
Please add some tests for primary keys of '', 0, '0', false, and 'false'.
Also while you're here, can we replace those two awful composite if statements with a static function? Something like getObjectPrimaryKey()
|
@najdanovicivan are you able to make these changes? If not, I'm closing. |
|
This also needs to be directed to |
|
I’m on it. |
42ce483 to
425b317
Compare
|
@MGatner we already have getIdValue() method so I've used it in place of those Regarding the other place where we have those nasty I also added couple of tests. I haven't worked with DataBase test before on CI so it took me a while to figure it out how those work. |
8d88227 to
c03d2de
Compare
faf9cbc to
2c32842
Compare
|
I'm not sure what's going on with test on 4.2 branch some of them are failing. What I also see now that MSSQL, SQLite and Postgres behave differently with empty values |
|
It looks like the failing tests are related to the way soft deletes are handled with primary keys. I'm on mobile so I can't dig very far right now, but some other tests might need changing for this to work. In general we have a few open issues/PRs around boolean/empty values in the database layer. I think these will all need to be pulled together and a final decision made on how to handle things before |
|
|
2c32842 to
1e5eb48
Compare
Primary key in SQL can have value of 0 or empty string. This modifies the model to use isset to handle such values instead of doing an empty chech so that rows wich such keys can be inserted/updated in the DB Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
1e5eb48 to
82ede90
Compare
|
Tests are still failing. |
|
I am seeing no progress in this since September. Please open a new PR with updated code where tests are passing. |
Description
Primary key in SQL can have value of 0 or empty string. This modifies the model to use isset to handle such values instead of doing an empty check so that rows which such keys can be inserted/updated in the DB
Checklist: