Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Added $leftJoinRelation#182

Merged
dekelev merged 16 commits intofeathersjs-ecosystem:masterfrom
wz5899:master
Apr 2, 2023
Merged

Added $leftJoinRelation#182
dekelev merged 16 commits intofeathersjs-ecosystem:masterfrom
wz5899:master

Conversation

@wz5899
Copy link
Contributor

@wz5899 wz5899 commented Sep 11, 2022

Added $leftJoinRelation. leftJoinRelation is supported by objection.js, but feathers-objection has no corresponding $leftJoinRelation.

@dekelev
Copy link
Member

dekelev commented Sep 14, 2022

Thanks @wz5899 , I'm not much available to review this in the next few weeks, but I'll check it out eventually.

@TalArbatov
Copy link

this seems like a good solution

@dekelev
Copy link
Member

dekelev commented Jan 6, 2023

Sorry, I haven't got the chance to review it yet and won't be able to do this in the next 2 weeks, but I'll keep a reminder.

wz5899 and others added 2 commits January 13, 2023 10:55
Fixed the issue in _find count when both $joinRelation and $leftJoinRelation are in the query.
@dekelev
Copy link
Member

dekelev commented Jan 20, 2023

@wz5899 Looks good to me. Please add a test to cover this new feature. Thanks for contributing!

@dekelev
Copy link
Member

dekelev commented Feb 27, 2023

Thanks @wz5899, I'll let you know once this is released.

@wz5899
Copy link
Contributor Author

wz5899 commented Feb 27, 2023 via email

@dekelev
Copy link
Member

dekelev commented Feb 27, 2023

@wz5899 Sure, I plan to test it locally before merging anyway. I'll also check later if I can fix the broken TravisCI integration. Regarding the sqlite3 error, I remember that, but I'm not sure how I worked around it, so if I'll remember or face this issue myself again, I'll update you here.

@dekelev
Copy link
Member

dekelev commented Mar 4, 2023

Thanks @wz5899, I ran the tests in your PR branch and there are 2 failed tests regarding "Join Eager/Relation queries".

You can run the tests now, just pull updates and install dependencies.

Also please delete the .vscode file from the remote branch. It should not be included here. You can add .vscode to the gitignore file or I'll add it later.

@dekelev
Copy link
Member

dekelev commented Mar 11, 2023

Thanks @wz5899, It looks good on SQLite, but your test fails on PostgreSQL with a "GeneralError: Unknown Database Error", not sure why.

You can test it out with changing the db variable in the index.test.js file to something like:

const db = knex({
  client: 'pg',
  debug: false,
  connection: {
    host: '127.0.0.1',
    port: 5432,
    user: 'user',
    password: 'password',
    database: 'test'
  },
  useNullAsDefault: false
});

Create the test PG database and run your test.

Note that not all tests are supposed to pass on PG, since some of them only work with SQLite.

@wz5899
Copy link
Contributor Author

wz5899 commented Mar 19, 2023

The "GeneralError: Unknown Database Error" in PostgreSQL seems from a bug in Objection or feathers-objection.

The error was caused by a query error:
DBError: select distinct "companies".* from "companies" inner join "clients" on "clients"."companyId" = "companies"."id" left join "employees" on "employees"."companyId" = "companies"."id"

For some unknown reason, Objection adds "distinct" before "companies".* in the generated PostgreSQL query. This throws an error. I have to add a groupBy in the query to suppress this distinct.

I saw another existing test "allow $modify query with paginate, groupBy and joinRelation" has the same issue. It uses a groupBy in $modify to work around. Without that groupBy, that test will give the same Unknown Database Error.

@dekelev
Copy link
Member

dekelev commented Mar 25, 2023

@wz5899 Thanks! it looks great. I saw another change though in an existing test that wasn't mentioned.

Can you please explain this change:

image

@wz5899
Copy link
Contributor Author

wz5899 commented Mar 29, 2023

I added an employee 'E' in ids.employees without an affiliated company in 'before' hook to test leftJoinRelation. That employee 'E' is at index 0 in the employee list fetched in "allows joinEager queries".

@dekelev
Copy link
Member

dekelev commented Mar 29, 2023

I see, thanks. Great work, I'll merge it later this week.

@dekelev dekelev merged commit aec4ba3 into feathersjs-ecosystem:master Apr 2, 2023
@dekelev
Copy link
Member

dekelev commented Apr 2, 2023

@wz5899 Thank you for your contribution! It's now released in v7.6.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants