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",
                 }
             }
      ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions