CodeDredd / pinia-orm

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
https://pinia-orm.codedredd.de/
MIT License
452 stars 39 forks source link

.first() will always execute withAllRecursive #1752

Closed pwfraley closed 6 months ago

pwfraley commented 11 months ago

Environment

Pinia ORM 1.7.2

Reproduction

this.userRepo.where("id", 1).first(); // This will always get all relational objects and subobjects { id: 1, name: 'admin', posts: [{ tilte: 'Cool post', body: 'Cool infos', },{},...] }

this.userRepo.where("id", 1).get()[0]; // This will only get the user { id: 1, name: 'admin', posts: [] }

Describe the bug

When using .first() to get an object the object is always return withAllRecursive, even though the query does NOT have withAllRecursive. So calling this: this.userRepo.where("id", 1).first(); is equal to: this.userRepo.withAllRecursive().where("id", 1).first();

Additional context

No response

Logs

No response

vesper8 commented 10 months ago

I was curious about this because I've been using pinia-orm for many months and have not encountered this.

I just tested it and this is not happening for me at all.

I compared useRepo(Product).query().first() vs useRepo(Product).query().withAllRecursive().first() and the former returned only the product attributes and none of its relationships and the latter did return all the nested relationships.

CodeDredd commented 6 months ago

@pwfraley Please provide a reproduction for it 🙏 .

CodeDredd commented 6 months ago

@pwfraley please reopen it if still occurs with v1.9.0. Thanks!