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

String null fix #2321

Merged
merged 4 commits into from
Jul 20, 2024
Merged

String null fix #2321

merged 4 commits into from
Jul 20, 2024

Conversation

dgilman
Copy link
Contributor

@dgilman dgilman commented Jan 19, 2023

This closes #1840. It is probably worth release noting as it is a behavior change.

Digging into the issue, [this comment](#1840 (comment) points out that String and Text don't handle falsey strings the same way. Digging into the history of the code, the difference originated with this commit which was a fix to #490. The author of that issue only brought up String fields, and the change only fixed String fields. I think it was simply an oversight to not handle Text fields the same way at that time, and it was likely because the opener of the ticket didn't happen to bring up both field types. The two classes were otherwise identical in behavior up until that PR.

The unit tests narrowly dodged the issue. Although there are nullable String columns none of them asserted on the casting of empty string to None, which probably would have made the inconsistency more obvious earlier on.

@samuelhwilliams
Copy link
Contributor

This looks good. I've just fixed up the test cases which needed to switch to some pytest fixtures and tweak indenting. Thanks for contributing 🙏

@samuelhwilliams samuelhwilliams merged commit 04315c5 into pallets-eco:master Jul 20, 2024
8 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

Unexpected differing behavior for db.String and db.Text on Postgres (latter saves empty field as "")
2 participants