feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.07k stars 751 forks source link

fix(memory/mongodb): $select as only property & force 'id' in '$select' #3081

Closed fratzinger closed 1 year ago

fratzinger commented 1 year ago

Quick fix for @feathersjs/memory.

First commit is the test which should work but fails without the second commit.

The problem was, that select(...) only was called if there was $sort, $limit or $skip in the query.

While being at it:

‼️ diffing behaviour of $select also returning id, also if not added explicitely.

I think that should be tested by @feathersjs/adapter-tests. We have it in:

This PR adds explicit tests to @feathersjs/adapter-tests and makes sure, that all tests pass for these linked tests.

fratzinger commented 1 year ago

This came up while porting feathers-graph-populate to dove (cc @marshallswain). Also for feathers-trigger.

This stops me from releasing dove versions of these two packages.

daffl commented 1 year ago

I think that makes sense. It looks like the virtual property resolver test needs to be updated accordingly. I'm also wondering if this could be considered a breaking change 🤔

DaddyWarbucks commented 1 year ago

Sorry gents! Glad yall got it worked out.

fratzinger commented 1 year ago

It looks like the virtual property resolver test needs to be updated accordingly.

The test expects two properties (I guess 'user' and 'text', but it's not clear). In reality it only returns 'text' (I double checked that). To get that fixed, I check now, if $select has virtual properties and if so then skip $select for adapter entirely. In some way this is, how the test was 'working' before.

I'm also wondering if this could be considered a breaking change

No, not at all. This was how every adapter was working in v4, even feathers-memory. Only @feathersjs/memory introduced a test to explicitly not adding service.id.