Skip to content

Invalid equality check of metadata objects #95

Closed

Description

@Crotalus

When searching for metadata for a specific metaobject this comparison is made:
metadata.target === target

https://github.com/typeorm/typeorm/blob/master/src/metadata-args/collection/EntityMetadataCollection.ts#L14
https://github.com/typeorm/typeorm/blob/master/src/metadata-args/collection/EntityMetadataCollection.ts#L18

Problem is that it fails to match against the same entity but included later in another file, I guess they aren't equal in the javascript object sense due to being separate objects in memory?

When changing the comparison to metadata.target.toString() === target.toString() it works as expected. I don't know if that's the optimal solution though.

Activity

  1. pleerock commented on Nov 20, 2016

    @pleerock
    Member

    no, its source code is correct. Probably you have something wrong setup in your code. It expects class/function type, and each one has its own instance. Provide your minimal code lets take a look where the issue is

  2. mohyt commented on Jul 16, 2018

    @mohyt

    @Crotalus : Do you have working code for this? I am also hitting same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions