Comments (7)
Nope, without using the Ref
wrapper, there is no difference between a populated and not populated relation property (on type level), without that the assignability cannot work properly - its not about comparing the populate hint, its about assignability of what the Loaded
type resolves.
from mikro-orm.
It would be technically possible to make this work without the Ref
wrapper, but it would be quite a breaking change. It's not just about the assignability of the Loaded
type itself in explicit hints, it would affect the assignability of relations in general.
Maybe something to think about when I start thinking about v7 (next year+).
from mikro-orm.
You need to use the Ref
wrapper on the M:1 properties, otherwise this cannot work.
from mikro-orm.
Alright, glad to know that's the issue. I figured that was likely the case, as it was resolved as soon as I added the Ref
attribute. That being said, the types still don't match so therefore it should throw an error, no? Because it errors as expected if you only add the non-ref M:1 relations into the populate
array, but as soon as you add the posts
collection in there, it seems to resolve fine.
from mikro-orm.
Well I have a lot of refactoring to do it seems given we did not use the Ref
property in the beginning...
from mikro-orm.
Not sure if it's worth it, tbh. It's kind of in the name: Type-Safe relations :P
from mikro-orm.
On second thought, it would be nice to have relations loaded via populate
and it affects the returned value, where any omitted values from the populate
array is simply omitted from the returned entity type not unlike Prisma. That would possibly eliminate the need for the Ref
type in its entirety. It would be a fundamental change however, but what are your thoughts on that? Possibly a means to do so would require that every entity extends BaseEntity
at least to some degree to pick up that it is an entity type. The Ref
type could be then be relegated to only situations of lazy-loading (possibly renamed to Lazy
or something).
from mikro-orm.
Related Issues (20)
- Populate order by not working with select-in strategy HOT 6
- Local timezone can't be used in mssql driver HOT 1
- em.upsert does not return or update entites already stored inside the entity manager
- Broken migration in 6.2.9 ?
- Table alias in Property formula not escaped correctly HOT 1
- Order of SQL parameters when using QueryBuilder with raw helper is not correct HOT 2
- tsserver performance issues caused by core imports HOT 2
- Correctly build where query for getSingleResult QueryBuilder method HOT 2
- ConstructorParams in metadata are not discovered correctly HOT 1
- Error when upserting null value for a nullable embeddable array property
- TypeError: undefined is not an object (evaluating 'previous.stack.split')
- Unable to Customize TypeScript Naming Strategy for Entities that are auto generated
- Error when batch updating null value for a nullable embeddable array property
- Issue with Generated Query When Using raw() Function in SQLite
- Index Creation Query is Generated Twice When Using Schema Generator in SQLite Driver Environment HOT 1
- Upsert entity with relation.
- @Property() with a name starting with __ are not included by default if no serialization groups are specified
- Query returns different BigInt value than the one stored in sqlite database HOT 2
- Issues with bidirectionalRelations Generation in Entity Models HOT 2
- Schema Generator always generates diff for vector(N) type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikro-orm.