nartc / mapper

🔥 An Object-Object AutoMapper for TypeScript 🔥
https://automapperts.netlify.app/
MIT License
980 stars 87 forks source link

Attributes that share common prefixes get skipped #583

Open erenteria-cu opened 11 months ago

erenteria-cu commented 11 months ago

Is there an existing issue for this?

Describe the issue

When mapping attributes with names that have similar prefixes, the attributes whose names that contain more than just the prefix get skipped.

For instance, if I have a source class like this:

class Src {

    @AutoMap()
    deleted: boolean;

    @AutoMap()
    deleted_by: number;

}

And a destination class like this:

class Dst {

    @AutoMap()
    deleted: boolean;

    @AutoMap()
    deletedBy: number;

}

And a mapping like this:

        createMap(
            mapper,
            Src,
            Dst,
            namingConventions({
                source: new SnakeCaseNamingConvention(),
                destination: new CamelCaseNamingConvention(),
            }),

When I try to map a source object to the destination, the destination only contains the deleted attribute. The deletedBy attribute is undefined.

Models/DTOs/VMs

class Dst {

    @AutoMap()
    deleted: boolean;

    @AutoMap()
    deletedBy: number;

}

class Dst {

    @AutoMap()
    deleted: boolean;

    @AutoMap()
    deletedBy: number;

}

Mapping configuration

        createMap(
            mapper,
            Src,
            Dst,
            namingConventions({
                source: new SnakeCaseNamingConvention(),
                destination: new CamelCaseNamingConvention(),
            }),

Steps to reproduce

No response

Expected behavior

I would expect both the deleted and deletedBy attributes to be properly mapped.

Screenshots

No response

Minimum reproduction code

No response

Package

Other package and its version

No response

AutoMapper version

8.7.6

Additional context

No response