test: add test which demonstrates incorrect JOIN clause for issue 1668 #4800
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: no fix here yet, just a new test case that demonstrates breakage when getting a relation using find when using postgres. Not tested on other DBs.
It gets a bit hairy to see what's going on as I tried to boil away anything that was related to the original problem domain. However you can make the query work by changing the following in the broken query:
ON C__a.aId="C"."aId"->ON "C__a"."id"="C"."aId"So, two problems. Double quotes are missing, and the id column is incorrect.
-- Original commit message follows
The problem demonstrated here is not exactly the same as in the original
issue for 1668. However the symptoms are similar. The original creator
of 1668 was experiencing a lack of double quotes around the table/column
name for a join condition. That matches this case. However there is an
additional problem where the column used to join to the related table is
also incorrect.
When running the tests, and viewing the database logs you can see the
following error:
2019-09-23 08:45:08.233 UTC [6013] ERROR: missing FROM-clause entry for table "c__a" at character 178
2019-09-23 08:45:08.233 UTC [6013] STATEMENT: SELECT "C"."aId" AS "C_aId", "C"."fooCode" AS "C_fooCode", "C"."barId" AS "C_barId", "C__a"."id" AS "C__a_id", "C__a"."name" AS "C__a_name" FROM "c" "C" LEFT JOIN "a" "C__a" ON C__a.aId="C"."aId" WHERE "C"."barId" = $1
Test for #1668