TypeError: Cannot read properties of undefined (reading 'databaseName')
I am using the configuration from the example using the repository method but it gives TypeError: Cannot read properties of undefined (reading 'databaseName'). TypeORM version 0.3.20 nestjs-paginate version 9.1.2
this is my service
async findAll(query: PaginateQuery): Promise<Paginated<Sessions>> {
try {
const result = await paginate(query, this.sessionRepo, {
relations: { files: true, transcript: true },
sortableColumns: ['id', 'name', 'is_active', 'timeTaken'],
nullSort: 'last',
defaultSortBy: [['created_at', 'DESC']],
searchableColumns: ['name', 'id', 'user_id', 'files.url'],
filterableColumns: {
user_id: [FilterOperator.EQ],
'files.url': [
FilterOperator.CONTAINS,
FilterOperator.EQ,
FilterOperator.ILIKE,
],
},
});
return result;
} catch (error) {
console.log(error);
}
}
Can you post the full error log please? And can you show how this.sessionRepo is created? I think there's going to be a not nestjs-paginate related error in your module setup. I'd need the error to know for sure.
I think this might be due to that 'files.url' part on the searchableColumns. I'm facing the same issue when trying to sort by a field inside a JSON column
I'm facing the same issue. It's related to the nullSort parameter in my case. When I remove it, it works fine!
I'm facing the same issue. It's related to the
nullSortparameter in my case. When I remove it, it works fine!
This worked for me too thanks
I think this might be due to that 'files.url' part on the searchableColumns. I'm facing the same issue when trying to sort by a field inside a JSON column
I think so too. I just encountered this issue while trying to sort on a relation column.
I'm facing the same issue. It's related to the
nullSortparameter in my case. When I remove it, it works fine!
It's not really a solution to remove things that are broken though, right? I would prefer nullSort or relation sorting to work the way it's advertised.
If I understand correctly there's 2 different issues going on here leading to the same error? One where nullSort causes the error, and one where using a JSON column causes the error? Could someone create a PR with reproducing test cases? Then I can look into a fix from there.
@Helveg I created a PR for the nullSort issue: https://github.com/ppetzold/nestjs-paginate/pull/1063
@AliRezaBeitari I did manage to fix it, by looking into typeorm source the problem is as usually inside :) and they have numerouse of bugs reporting this error
https://github.com/ppetzold/nestjs-paginate/pull/1089
I did manage to fix it, by adding a field to select statement and sort by it, that way typeorm can recognise this field when we have join... it works, and it isolated to mysql and nulllast functionality, so I think it relatively safe to merge it, no breaking changes expect
@Helveg @ppetzold please take a look when time allows
fixed in #1089 ! :)