-
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
[Model] Upsert problem with data validation, allowed fields, dates defined #7286
Comments
What are the current outputs? $model->errors();
$model->db->getLastQuery()->getQuery(); |
This is not a bug.
The model does not have the |
By the way, why do you need to use |
When we need to save something, we use |
Output for the $model->errors(); // returns `null`, should be a validation error for the item_id field Output for the method $model->db->getLastQuery()->getQuery(); INSERT INTO `table` (`col1`, `item_id`, `item_quantity`)
VALUES ('string data','string data',99)
ON DUPLICATE KEY UPDATE
`table`.`col1` = VALUES(`col1`),
`table`.`item_id` = VALUES(`item_id`),
`table`.`item_quantity` = VALUES(`item_quantity`) |
No, no. It was just added in Query Builder. As you know, not all Query Builder methods work with the Model. This is not a bug, just the current Model does not support the method. |
PHP Version
7.4
CodeIgniter4 Version
4.3.2
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
Windows, Linux
Which server did you use?
apache
Database
MySQL (ver. 8.0.28)
What happened?
Upsert does not work correctly with the model.
Allowed fields, validation rules, dates (created_at, updated_at) are defined within the model, this does not apply to the query.
The model should throw validation errors first!
Steps to Reproduce
Expected Output
Anything else?
No response
The text was updated successfully, but these errors were encountered: