Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array property with object items not loaded correctly #730

Open
leanil opened this issue Apr 17, 2023 · 0 comments
Open

Array property with object items not loaded correctly #730

leanil opened this issue Apr 17, 2023 · 0 comments
Labels

Comments

@leanil
Copy link

leanil commented Apr 17, 2023

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.

@leanil leanil added the bug label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant