Skip to content

Array property with object items not loaded correctly  #730

@leanil

Description

@leanil

Steps to reproduce

Define a model with an array property, where the item type contains a buffer.

@model()
export class DemoModel extends Entity {
  @property.array(Item)
  items: Item[];
}

@model()
export class Item extends Model {
  @property()
  buffer: Buffer;
}

Store and load an instance of this model.

await this.demoModelRepository.create({items: [{buffer: Buffer.from('data')}]});
const demo = await this.demoModelRepository.findOne();
console.log(demo?.items[0].buffer.toString())

Current Behavior

Prints nothing. The buffer in the loaded object is empty.

Expected Behavior

Prints "data".

Link to reproduction sandbox

https://github.com/leanil/array-prop-bug
(Just npm start it, the observer performs the test on start.)

Additional information

linux x64 16.17.0

├── @loopback/boot@5.0.9
├── @loopback/core@4.0.9
├── @loopback/repository@5.1.4
├── @loopback/rest-explorer@5.0.9
├── @loopback/rest@12.0.9
├── @loopback/service-proxy@5.0.9
├── loopback-connector-mongodb@6.2.0

Behaves the same way with 7.0.0-alpha.1.
The absence of an array case around here seems suspicious to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    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