-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: CI4 set ID to NULL when I try insert a row #2557
Comments
Make your primary key auto-increment. The Entity expects an auto-incrementing primary key. I thought we had gone back and made that explicit in the user guide but I'm not finding it so that's something we should add. Not a bug, though. It's intended this way. |
@lonnieezell it is autoincrement, but for autoincrement work, we don`t must set field http://prntscr.com/r2gkhf http://prntscr.com/r2gm8v I have postgres |
I'm not the most familiar with working with Postgres, but I thought auto-incrementing was only for the |
@lonnieezell this is still a bug |
@lonnieezell @MGatner open pls this issue. Can we add this check? && isset($data->{$primaryKey}) to if (! empty($properties) && ! empty($primaryKey) && ! in_array($primaryKey, $properties))
{
$properties[$primaryKey] = $data->{$primaryKey};
} File https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Model.php |
This code:
breaks all my app. When I try to insert a row, in example this row:
name: John
age: 21
CodeIgniter add field from primaryKey and fill value to NULL. And postgres got error because id can`t be null
Code for reproduction:
The text was updated successfully, but these errors were encountered: