fix: query localized fields without localization configured
This commit is contained in:
@@ -449,7 +449,7 @@ export class ParamParser {
|
||||
// Skip the next iteration, because it's a locale
|
||||
i += 1;
|
||||
currentPath = `${currentPath}.${nextSegment}`;
|
||||
} else if ('localized' in matchedField && matchedField.localized) {
|
||||
} else if (this.localizationConfig && 'localized' in matchedField && matchedField.localized) {
|
||||
currentPath = `${currentPath}.${this.req.locale}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,12 @@ export default buildConfig({
|
||||
name: 'number',
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
name: 'fakeLocalization',
|
||||
type: 'text',
|
||||
// field is localized even though the config localization is not on
|
||||
localized: true,
|
||||
},
|
||||
// Relationship
|
||||
{
|
||||
name: 'relationField',
|
||||
|
||||
@@ -469,6 +469,24 @@ describe('collections-rest', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Edge cases', () => {
|
||||
it('should query a localized field without localization configured', async () => {
|
||||
const test = 'test';
|
||||
await createPost({ fakeLocalization: test });
|
||||
|
||||
const { status, result } = await client.find({
|
||||
query: {
|
||||
fakeLocalization: {
|
||||
equals: test,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(status).toEqual(200);
|
||||
expect(result.docs).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Operators', () => {
|
||||
it('equals', async () => {
|
||||
const valueToQuery = 'valueToQuery';
|
||||
|
||||
@@ -23,6 +23,7 @@ export interface Post {
|
||||
title?: string;
|
||||
description?: string;
|
||||
number?: number;
|
||||
fakeLocalization?: string;
|
||||
relationField?: string | Relation;
|
||||
relationHasManyField?: string[] | Relation[];
|
||||
relationMultiRelationTo?:
|
||||
@@ -55,6 +56,7 @@ export interface Post {
|
||||
relationTo: 'dummy';
|
||||
}
|
||||
)[];
|
||||
restrictedField?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -66,6 +68,7 @@ export interface Relation {
|
||||
}
|
||||
export interface Dummy {
|
||||
id: string;
|
||||
title?: string;
|
||||
name?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
Reference in New Issue
Block a user