Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #38197 - Allow unsetting settings with nil defaults #10435

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

adamruzicka
Copy link
Contributor

No description provided.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Code makes sense to me and I'd trust the tests.

I wonder if we should start avoiding nil as default and rely on empty strings, but don't have a good view on the impact so this is probably a good start. Did you consider that option too?


assert s.save
assert_nil s.value
assert_nil s.read_attribute(:value)
Copy link
Member

Choose a reason for hiding this comment

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

For my understanding, why this in addition to s.value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a bit of a stretch, but in theory it could happen that s.value would be nil, but the db field would be a nil serialized to yaml (---\n) instead of a proper null

@ekohl ekohl changed the title Fixes #38197 - Allow usetting settings with nil defaults Fixes #38197 - Allow unsetting settings with nil defaults Feb 10, 2025
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

👍 but do you mind fixing the typo in the commit message?

@adamruzicka
Copy link
Contributor Author

Done, test failures seem unrelated.

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

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

Thanks, @adamruzicka and @ekohl !

@ofedoren ofedoren merged commit 8b1bd8f into theforeman:develop Feb 12, 2025
28 of 31 checks passed
@adamruzicka adamruzicka deleted the nil-string-setting branch February 13, 2025 10:32
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.

3 participants