Skip to content

Improved omitempty tag and added support for omitnil#29

Merged
OrCh3n merged 1 commit intoroneli:mainfrom
aviadgal:aviadgal-add-omitnil-support
Apr 20, 2025
Merged

Improved omitempty tag and added support for omitnil#29
OrCh3n merged 1 commit intoroneli:mainfrom
aviadgal:aviadgal-add-omitnil-support

Conversation

@aviadgal
Copy link
Contributor

Added support for the omitnil tag for cases where we want to skip insert/update of nil fields

if dbTag := f.Tag.Get(tagNameDb); dbTag != "" {
if strings.Contains(dbTag, omitEmpty) {
if value.IsZero() {
if !value.IsValid() || value.IsZero() { // IsZero panic on valid values
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since when does it panic? Is it related to the nil pointer dan made?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OrCh3n OrCh3n merged commit f54ab10 into roneli:main Apr 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants