Skip to content

Cannot set property 'mapping' of undefined #117

Description

@kbarbounakis

Describe the bug
An error occurred while a model which is inherited by another model has a "tag" type mapping e.g.

{
      "name": "Product",
      "fields": [
             ...
             {
                 "name": "keywords",
                  "type": "Text",
                  "many": true
             }
      ]
}

where Product.keywords is a collection of strings and Vehicle model inherits Product without overriding keywords attribute

{
      "name": "Vehicle",
      "inherits": "Product"
      "fields": [
             ...
             
      ]
}

DataModel.inferMapping() throws an exception of an undefined attribute. Overriding an attribute is an optional action and should be used here without throwing error.

Workaround
Override attribute but also define associationAdapter e.g.

{
      "name": "Product",
      "fields": [
             ...
             {
                 "name": "keywords",
                  "type": "Text",
                  "many": true,
                 "mapping": {
                         "associationAdapter": "ProductKeywords",
                 }
             }
      ]
}

and

{
      "name": "Vehicle",
      "fields": [
             ...
             {
                 "name": "keywords",
                  "type": "Text",
                  "many": true,
                 "mapping": {
                         "associationAdapter": "ProductKeywords",
                 }
             }
      ]
}

Activity

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