Skip to content

Array property with object items not loaded correctly  #730

Open
@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/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── [email protected]

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions