pinia-orm icon indicating copy to clipboard operation
pinia-orm copied to clipboard

.first() will always execute withAllRecursive

Open pwfraley opened this issue 1 year ago • 2 comments

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

pwfraley avatar Dec 12 '23 13:12 pwfraley

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.

vesper8 avatar Jan 17 '24 00:01 vesper8

@pwfraley Please provide a reproduction for it 🙏 .

CodeDredd avatar May 05 '24 16:05 CodeDredd

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

CodeDredd avatar May 08 '24 06:05 CodeDredd