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

Lazy flag not respected for Formulas #1229

Closed
jeesus opened this issue Dec 22, 2020 · 1 comment
Closed

Lazy flag not respected for Formulas #1229

jeesus opened this issue Dec 22, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jeesus
Copy link

jeesus commented Dec 22, 2020

Describe the bug
When formula is being defined by Property() decorator and is assigned lazy: true flag, the field gets always populated.

To Reproduce
Steps to reproduce the behavior:

  1. Add following property to tests/entities-sql/Book2.ts
@Property({
    formula: alias => `${alias}.price * 1.19`,
    lazy: true,
  })
  lazyPriceTaxed?: number;
  1. See tests fail since it's a lazy property no test has asked to populate, but it still does get populated

Expected behavior
Expected the field to be populated only when instructed so.

Versions

Dependency Version
node 12.16.1
typescript 4.0.3
mikro-orm 4.2.1
mikro-orm/mysql 4.2.1
@B4nan B4nan added the bug Something isn't working label Jan 5, 2021
@B4nan B4nan closed this as completed in 4b2b5ce Jan 6, 2021
@B4nan
Copy link
Member

B4nan commented Jan 6, 2021

This ended up as quite hard to fix, lol :] Also fixed another issue with lazy properties and joined loading on the way.

Once built, you can try this via 4.3.5-dev.49.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants