Replies: 1 comment
-
I found the exact same situation. I assume this is a bug and you should convert this discussion into a bug issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have an account table, it has an optional 1 to 1 mapping to a subscription table via fk_account_id on the subscription. Something like this:
If I try to load these nested relationship I can do it either using the Preload/Join initially or lazy load them later if they are missing. Something like this:
later in the code if I need the subscription I test if it was loaded and if not I lazy load it
Assuming there is a subscription associated with the account this all works great. But if there is no subscription related to the account rather than the
account.Subscription == nil
being true it is a struct with an empty value which can be hard to tell a part form an empty row in the table.Worse still when I call the
Association("Subscription").Find(&acc.Subscription)
above to lazy load it (this could happen because I did not join it originally, or if the Join would set the Subscription to nil like I was expecting) ... But this still just sets theacc.Subscription
to be a empty struct, notnil
and not returning agorm.ErrRecordNotFound
error.So my 2 questions are:
Thanks for any help with this !!
Beta Was this translation helpful? Give feedback.
All reactions