cast to class does not work with Value<T>
Closed this issue · 1 comments
buchatsky commented
Steps to reproduce
The following test fails:
const prv = new MockRequestProvider({ value: getCompanies() });
const svc = new ODataService("api", prv);
const result = await svc.createQuery<ICompany>("Companies").inlineCount().toArrayAsync(Company);
result.value.forEach((r) => expect(r).to.be.instanceOf(Company));
Expected behavior
plainToClass() to be applied to the nested value object (either array or a single object) in case of inlineCount or responce options.
Actual behavior
plainToClass() is applied to the surrounding Value literal, not to its value.
When query returns an array, and ctor represents a class, its constructor is fired only once on the Value object.
jinqu-odata version
1.1.3
buchatsky commented
Again, have a fix but cannot create a clear PR till you merge the previous one.
PS. Kiev is under missles attacks from time to time, every my row of code can be the last)