Closed atharahmed closed 2 years ago
Hi @atharahmed Can you send callstack of error "Cannot read properties of undefined (reading 'method')"?
Please see attached image:
I'm trying to test the suggested fix a fork of the package.
I don't think what replace toQuery
to toSQL
will fix this issue. Both methods call applyWhere()
where this error occurs
Need check why firstItem
is undefined.
My suggested fix does not work but it seems like when you transform the lucid object to SQL query it adds an empty array in chainable of lucid which throws the error.
You can recreate the issue by replacing .preload('authors', (authors) => authors.groupLimit(2))
with .preload('authors', (authors) => authors.where('name', 'John'))
in relations.spec.ts
file line 226
Fixed in v1.4.2
Hi,
Recently I updated Adonis, Lucid, and soft-deletes to their latest versions, and now where query in preload is broken.
Following are the version updates:
@adonisjs/core ^5.5.3 → ^5.8.3
@adonisjs/lucid ^17.1.0 → ^18.0.0
adonis-lucid-soft-deletes ^1.3.3 → ^1.4.1
I get the "Cannot read properties of undefined (reading 'method')" error.
So I inspected to find the error and seems like the issue is caused by the
toQuery()
method on line 32 of the following file: https://github.com/lookinlab/adonis-lucid-soft-deletes/blob/develop/src/SoftDeletes/index.tsReplacing
const isGroupLimitQuery = query.toQuery().includes('adonis_group_limit_counter')
withlet sqlQuery = query.toSQL().toNative()
const isGroupLimitQuery = sqlQuery.sql.includes('adonis_group_limit_counter');
seem to fix the issue.I can create a PR if that helps.
Thanks