-
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
SQL JOIN : bad aliasing on join with prefixed db tables #1599
Comments
Please provide an example query that can recreate this issue as what you're showing here looks to be deep in a bunch of custom code with no way for us to actually know if the issue is with the core framework or how it's being used. |
this is the Query in StoresController
and this is the model
|
the above code is fixed by adding the prefix |
So the core issue is that the prefix is not added to the aliased table? In the original example you gave it looks like the issue is that it's not escaping the aliased field correctly. All of the table names that you have boxed in your example show the same, and presumably correct, table name, I really didn't need your entire model here, just a small example that allows me to reproduce an error. Can you provide a (much) smaller, encapsulated example of the core issue here soI can test it easier? |
So the core issue is that the prefix is not added to the aliased table? All of the table names that you have boxed in your example show the same, and presumably correct, table name, basicaly when I use the alias, I expect that the db core class take the alias as it is to build the fields list, but in this case, it takes the alias and prefix it with the I faced this issue when I used a separated join as shown on the model, and therefore I have put the concerned part of my model above |
more details : I believe, the issue is related to this join syntax
basicaly, the columns must be called on |
Cannot replicate. If you provide simpler, CI-only code that can demonstrate the example, I'll take a look again. I've added a couple of tests to the AliasTest, though, and not seeing any issues. |
name: bad aliasing when using prefix on tables in join
about: when using prefix on db tables, the aliased table must match to the join table, both uses the prefix or both not to use it.
Describe the bug
miss match of tables names when using prefix and join, the db tables "dotted" to fields list built by the core class dont match to the supplied ones
CodeIgniter 4 version
all versions and commits
Affected module(s)
Database
Expected behavior, and steps to reproduce if appropriate
the expected behaviour is that the aliasing must match between the aliased tables by the core class and given one by the application
temporary fix
as shown above, the aliasing is not matching, the
on
condition is on the expected alias but the table aliasing with AS is prefixed which it must not be ^^i could not use event to debug sql error, hence i used ajax request to see the query ^^
would u please add an example of using dbquery debugger on the "event" in docs
Context
The text was updated successfully, but these errors were encountered: