JonasHiltl / openchangelog

Easy to configure & self hostable Changelog Website
https://openchangelog.com
GNU Affero General Public License v3.0
153 stars 9 forks source link

Improve handling of optional values #7

Closed JonasHiltl closed 2 months ago

JonasHiltl commented 2 months ago

Some changelog values like title, domain, ... are optional strings, so they can be a string or NULL in db. When updating these fields through a PATCH request we need to differentiate between a null, zero and defined value, to be able to either unset the value, keep the old value or overwrite it.

This is my proposal on how to handle user input through the API: JSON Action
null set to NULL
missing or zero value keep old value
defined overwrite DB value

I currently could not find a go package that provides these information from marshalled fields, so I probably need to write my own package, to get access to the information IsNull(), IsZero(), String()