Skip to content

Unscoped not working with PreLoad on Joins #6054

@manstis

Description

@manstis

Your Question

Before I report a bug I wanted to check if my expectation is correct.

I have a reproducer here that sets up some Models with a 1-to-many Foreign Key.

=UNSCOPED LOAD====================

2023/02/13 19:08:53 /...../gorm-playground/main_test.go:44
[0.162ms] [rows:0] SELECT * FROM `addresses` WHERE `addresses`.`id` = 1 AND `addresses`.`deleted_at` IS NULL

The store and fetch works fine however if I (soft) delete the children I am unable to load the compete model back with unscoped.

I was hoping (or expecting) unscoped to allow retrieval of the whole model including soft deleted children.

The document you expected this should be explained

https://gorm.io/docs/delete.html#Soft-Delete

Expected answer

Am I doing it wrong, or is it a bug? I see there have been various issues with soft delete/PreLoad/Joins in the past.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions