-
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: useSoftDeletes with like function #2380
Comments
@edica I wasn't able to replicate this issue. I have 4 Factories in the database all with "fas ..." icons, one with $factories = new \App\Models\FactoryModel();
$data = [
'orLike' => $factories->orLike(['icon' => 'fas'])->paginate(5),
'where' => $factories->where('id <', 4)->paginate(5),
];
Can you pull the latest You can also harvest the actual database queries generated from the Debug Toolbar. For example, from mine above: 0.89 ms | SELECT COUNT(*) AS `numrows` FROM `dev_factories` WHERE `icon` LIKE '%fas%' ESCAPE '!' AND `dev_factories`.`deleted_at` IS NULL
0.95 ms | SELECT * FROM `dev_factories` WHERE `icon` LIKE '%fas%' ESCAPE '!' AND `dev_factories`.`deleted_at` IS NULL AND `dev_factories`.`deleted_at` IS NULL LIMIT 5
0.97 ms | SELECT COUNT(*) AS `numrows` FROM `dev_factories` WHERE `id` < 4 AND `dev_factories`.`deleted_at` IS NULL
0.88 ms | SELECT * FROM `dev_factories` WHERE `id` < 4 AND `dev_factories`.`deleted_at` IS NULL AND `dev_factories`.`deleted_at` IS NULL LIMIT 5 |
No response from user. |
Am on CodeIgniter 4.3.3 and experiencing the same issue. orLike returns deleted records as well. |
@MGatner Same thing on 4.4.5. |
Check the SQL statement that are generated in the Debug Toolbar. |
@kenjis Thanks for the tip. It seems that the like() and orLike() statements are not grouped together when the deleted_at is present. I had to explicitly group them together. |
Describe the bug
Practicing through the tutorial below. Using useSoftDeletes, and the fields indicated created_at, updated_at and deleted_at. Everything is working fine. But when I do a search with "where()" it doesn't show deleted records. Already using "like()" shows all deleted ones as well. like() should also not show deleted ones?
https://codeigniter4.github.io/CodeIgniter4/tutorial/news_section.html
CodeIgniter 4 version
CodeIgniter-4.0.0-rc.3
Affected module(s)
Unknown
Expected behavior, and steps to reproduce if appropriate
Shows deleted register:
Do not show deleted register:
Context
The text was updated successfully, but these errors were encountered: