-
Notifications
You must be signed in to change notification settings - Fork 643
Closed
Labels
Description
Hi,
I stumbled upon an issue with aliasFor, it doesn't seem to work when used with a query directly, like described in the docs. But everything seems to work fine if used with $relatedQuery.
I used the reproduction template to test it (I added an extra property named someProp):
const jennifer = await Person.query().findOne({ firstName: 'Jennifer' });
// this works fine
const jenniferMovies = await jennifer
.$relatedQuery('movies')
.aliasFor('Person_Movie', 'pm')
.where('pm.someProp', 100);
// this doesn't alias Person_Movie correctly and throws an error because pm is not known
const jenniferWithMovies = await Person.query()
.findOne({ firstName: 'Jennifer' })
.aliasFor('Person_Movie', 'pm')
.joinRelated('movies')
.where('pm.someProp', 100);
This also explains why the test pass: They only test for the case with the $relatedQuery.
This should be working, or am I missing something?