-
Notifications
You must be signed in to change notification settings - Fork 20
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
associations and custom schema generates wrong query #75
Comments
The alias was necessary to differentiate between different relationships. If you have multiple relationships that use the same mapping table, this would cause incorrect results. This is an edge case where you are using schema. Is there a particular reason why you are specifying the schema? You can set the schema that you want to use in your knexfile (searchPath) if you are using something other than public. |
Ok. That sounds logical. I know this sounds very ugly, but we have a project with multiple seperated applications in it and they all use the same database. |
We could make a change to replace |
@sl-ffx Do you want to make this change or should I do it? |
Can you make this change? |
To run the tests you need to create a postgres database. The details for
the connection are in the test file.
You can also make a PR and I can run the tests.
…On Wed, Jul 14, 2021, 11:52 PM Stefan Laimer ***@***.***> wrote:
Can you make this change?
I'm not able to run the tests. It always stuck in the before hook in the
common.js and I don't want to push anything without testing it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUMB55CRD3WWLBGC4H5KXTTXZZR3ANCNFSM5ALC3AYQ>
.
|
Yea.. I used an existing postgres database and created the role + database. I don't even get any outputs on setting Ok. If you can run the tests for me I'm going to create a PR. |
Created PR #76 |
Hi,
The bookshelf-jsonapi-params generates a query which failes on postgres. Maybe it's a special case, because we are using the postgres schema.
The problem is on these lines. The
joinTableName
also contains the schema. Because the alias ("as") does not distinguish the schema it interprets the name as"roles_custom.roles_users"
. But the third argument distinguish the schema and interprets the name as"roles_custom"."roles_users"."role_id"
.That's why postgres throws the error
missing FROM-clause entry for table "roles_users"
.My question: Is the alias in the join statement needed?
If I remove the aliases the code works as expected.
Here is an example to reproduce
Here is the full error
The text was updated successfully, but these errors were encountered: