You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I don't seem to find a builtin way of removing this relationship from model A (i.e. set the virtual column to NULL). When I set the value for B on the model struct of A to nil it is just ignored. From looking at the code this appears to be, because the virtual column is never modified if B is nil. Since it still holds the value that was queried it'll just set the foreign key to what it was before. Calling ClearVirtualColumns on the model removes the previous value, but also causes it to be ignored on the update call.
After some tinkering I did find a workaround that allows me to properly clear the column, but I feel this should somehow be handled by kallax, because the workaround relies on the AddVirtualColumn method, which is supposed to be used for internal purposes only. It's just some glue code around using the stdlib sql.NullInt64 as a kallax.Identifier in the call to AddVirtualColumn.
Kallax is unable to do this at the moment, but it is definitely high up on my task list. This has been mentioned before (#219), but again it's something that conflicts directly with the n:m relationship management. It will be implemented right after n:m relationships.
I'm closing this as dupe, please continue discussing this matter on #219.
Hello,
I have a model
A
that contains an optional inverse 1:1 relationship to modelB
like this:However, I don't seem to find a builtin way of removing this relationship from model
A
(i.e. set the virtual column toNULL
). When I set the value forB
on the model struct ofA
tonil
it is just ignored. From looking at the code this appears to be, because the virtual column is never modified ifB
isnil
. Since it still holds the value that was queried it'll just set the foreign key to what it was before. CallingClearVirtualColumns
on the model removes the previous value, but also causes it to be ignored on the update call.After some tinkering I did find a workaround that allows me to properly clear the column, but I feel this should somehow be handled by kallax, because the workaround relies on the
AddVirtualColumn
method, which is supposed to be used for internal purposes only. It's just some glue code around using the stdlib sql.NullInt64 as a kallax.Identifier in the call toAddVirtualColumn
.Is there a chance for kallax to support this use-case natively?
The text was updated successfully, but these errors were encountered: