-
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: shared BaseBuilder instance and Model #4461
Comments
Are you trying to override the table given in the model? I'm assuming that's what you're doing. And that goes against how the Models are designed to work. The problem is I don't see what it is you're trying to have happen - you just point out how it doesn't do what you're expecting. You can always grab a new QueryBuilder with either If you're outside of the model trying to use that query, then you can get it using something like |
BaseBuilder has no paginate() method. It is only defined in BaseModel() |
@kenjis Good idea, but for some reason I am plagued by doubts. It seems that some nuance is slipping out of sight. |
@iRedds $builder->from('(SELECT id, name FROM test_1) t', true);
So it seems this is simply misuse and it is not a bug. |
@kenjis |
@iRedds Is this issue still there? |
Yes. Nothing changed. I won't mind if this issue is closed. |
Thanks. I forgot the details of the issue, but I thought recent development of Query Builder might change this. As I sent a PR, I thought there was a problem. |
A solution may emerge from a discussion where all parties have an understanding of the situation or a desire to understand it. Because a possible solution may be at the level of the concept of working with a model and a database. |
Describe the bug
Wrong approach to implementing a generic BaseBuilder instance in the model and post processing queries to the database.
When using a subquery, the work of the model / builder breaks.
The fact is that after the query is executed, the table is reassigned.
CodeIgniter4/system/Database/BaseBuilder.php
Lines 3396 to 3400 in de8d7f4
For the first case, the value will be:
(SELECT * FROM test_1) t
For the second case:
(SELECT id
, because the from() method can accept as a table name a string consisting of several tables separated by commas: from('table_1, table_2, table_3)Affected module(s)
Model, BaseBuilder
You can fix this with crutches, but I think it's time to change the concept of the model and query builder.
The text was updated successfully, but these errors were encountered: