Nested Preload function under belongsTo preload is not running.
Package version
"@adonisjs/auth": "^8.2.3",
"@adonisjs/bouncer": "^2.3.0",
"@adonisjs/core": "^5.9.0",
"@adonisjs/lucid": "^18.3.0",
"@adonisjs/mail": "^7.2.4",
"@adonisjs/repl": "^3.1.6",
"@adonisjs/session": "^6.4.0",
"@adonisjs/view": "^6.1.0",
Node.js and npm version
% node -v
v16.16.0
% npm -v
8.11.0
Sample Code (to reproduce the issue)
const strategy = await StrategyRepository.findByUidForUser(params.strategyId)
public findByUidForUser(uid: string) {
return Strategy.query()
.where('uid', uid)
.preload('account', (accountQuery) => {
console.log('i ran')
accountQuery.preload('users')
})
.firstOrFail()
}
i ran is not being printed.
select * from "Strategies" where "uid" = ? limit ? [ 'btQ3a', 1 ]
select * from "Accounts" where "id" in (?) [ 1 ]
are SQL outputs
Strategy.ts
@column()
public accountId: number
@belongsTo(() => Account)
public account: BelongsTo<typeof Account>
Account.ts
@manyToMany(() => User, {
pivotTable: 'UserAccounts',
pivotForeignKey: 'accountId',
pivotRelatedForeignKey: 'userId',
})
public users: ManyToMany<typeof User>
BONUS (a sample repo to reproduce the issue)