-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use array to store paths #303
Conversation
@nartc I have a note about this line: mapper/packages/core/src/lib/map/map.ts Line 226 in f7e89d6
Is it on purpose to start in reverse order? I assumed that |
It is. Because in initializeMapping, I do start in |
It's true that
My expectation was that when I use // example test
export const deepNestedFooFooFooProfile: MappingProfile = (mapper) => {
mapper.createMap(FooFooFoo, FooFooFooDto).forMember(
(dest) => dest.foo,
fromValue('FooFooFoo Custom Value')
);
mapper.createMap(FooFoo, FooFooDto).forMember(
(dest) => dest.foo.foo,
fromValue('FooFoo Custom Value')
);
mapper.createMap(Foo, FooDto).forMember(
(dest) => dest.foo.foo.foo,
fromValue('Foo Custom Value')
);
};
// Succeed
it('should map forMember override properly', () => {
mapper.addProfile(deepNestedFooFooFooProfile);
const foo = new FooFooFoo();
foo.foo = 'some value';
const vm = mapper.map(foo, FooFooFooDto, FooFooFoo);
expect(vm).toBeTruthy();
expect(vm.foo).toEqual('FooFooFoo Custom Value');
});
// Failed
it('should map inner forMember override properly', () => {
mapper.addProfile(deepNestedFooFooFooProfile);
const foo = new FooFoo();
foo.foo = new FooFooFoo();
foo.foo.foo = 'some value';
const vm = mapper.map(foo, FooFooDto, FooFoo);
expect(vm).toBeTruthy();
expect(vm.foo.foo).toEqual('FooFoo Custom Value'); // <= Received: "FooFooFoo Custom Value"
});
// Failed
it('should map deep inner forMember override properly', () => {
mapper.addProfile(deepNestedFooFooFooProfile);
const vm = mapper.map({ foo: {foo: { foo: 'some value' }} }, FooDto, Foo);
expect(vm).toBeTruthy();
expect(vm.foo.foo.foo).toEqual('Foo Custom Value'); // <= Received: "FooFooFoo Custom Value"
}); I'm not sure if this behavior is intended or not, but in the previous version, I was able to override the inner properties. |
That is definitely a bug imho. If we change from |
It could be
It could be just the normal order with |
I’m fine with push + normal order as well. We can go with that. If that’s the case, we can actually convert all reverse loops to normal loops? |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
I have changed other reversed loops to normal loops 👍 |
Thanks man. I'll be reviewing this today! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the PR. LGTM. It actually cleans up quite a bit.
Solve #299