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
|
// Skip the next iteration, because it's a locale
|
||||||
i += 1;
|
i += 1;
|
||||||
currentPath = `${currentPath}.${nextSegment}`;
|
currentPath = `${currentPath}.${nextSegment}`;
|
||||||
} else if ('localized' in matchedField && matchedField.localized) {
|
} else if (this.localizationConfig && 'localized' in matchedField && matchedField.localized) {
|
||||||
currentPath = `${currentPath}.${this.req.locale}`;
|
currentPath = `${currentPath}.${this.req.locale}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ export default buildConfig({
|
|||||||
name: 'number',
|
name: 'number',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'fakeLocalization',
|
||||||
|
type: 'text',
|
||||||
|
// field is localized even though the config localization is not on
|
||||||
|
localized: true,
|
||||||
|
},
|
||||||
// Relationship
|
// Relationship
|
||||||
{
|
{
|
||||||
name: 'relationField',
|
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', () => {
|
describe('Operators', () => {
|
||||||
it('equals', async () => {
|
it('equals', async () => {
|
||||||
const valueToQuery = 'valueToQuery';
|
const valueToQuery = 'valueToQuery';
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export interface Post {
|
|||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
number?: number;
|
number?: number;
|
||||||
|
fakeLocalization?: string;
|
||||||
relationField?: string | Relation;
|
relationField?: string | Relation;
|
||||||
relationHasManyField?: string[] | Relation[];
|
relationHasManyField?: string[] | Relation[];
|
||||||
relationMultiRelationTo?:
|
relationMultiRelationTo?:
|
||||||
@@ -55,6 +56,7 @@ export interface Post {
|
|||||||
relationTo: 'dummy';
|
relationTo: 'dummy';
|
||||||
}
|
}
|
||||||
)[];
|
)[];
|
||||||
|
restrictedField?: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
@@ -66,6 +68,7 @@ export interface Relation {
|
|||||||
}
|
}
|
||||||
export interface Dummy {
|
export interface Dummy {
|
||||||
id: string;
|
id: string;
|
||||||
|
title?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user