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
I think it would be valuable to add a mechanism for partial updates to ormx similar to what the AsChangeset derive from diesel does.
There are however various possible solutions, the most straightforward one being to require all fields in Patch structs to be wrapped in an Option:
None would not perform the update for the field
Some(None) would set a nullable field to NULL
Some(Some(val)) would set a nullable field to val
Some(val) would set a non-nullable field to val
I started discussing this on the discord and @NyxCode kindly responded with interesting alternative ideas that I think are very much worth exploring. I'm quoting their message here to help start the discussion:
yeah so I did think about this a bit in the past.
I found that in most cases, it's most comfortable to avoid having to deal with nested Options and stuff like you would have to with diesel. That's also what I needed the most at the time.
I do think supporting this would be great though! Would having an attribute like #[ormx(ignore_if_none)] (that name is mediocre, im sure we can come up with something better) work when deriving Patch?
I guess we would need something a bit more sophisticated when we still want to be able to derive Patch for the same struct which represents the Table
Regardless, I'd definetely appraciate if you would open an issue for this, possibly outlining possible approaches like this
The text was updated successfully, but these errors were encountered:
I think it would be valuable to add a mechanism for partial updates to
ormx
similar to what theAsChangeset
derive from diesel does.There are however various possible solutions, the most straightforward one being to require all fields in
Patch
structs to be wrapped in an Option:None
would not perform the update for the fieldSome(None)
would set a nullable field toNULL
Some(Some(val))
would set a nullable field toval
Some(val)
would set a non-nullable field toval
I started discussing this on the discord and @NyxCode kindly responded with interesting alternative ideas that I think are very much worth exploring. I'm quoting their message here to help start the discussion:
The text was updated successfully, but these errors were encountered: