-
Notifications
You must be signed in to change notification settings - Fork 45
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
Fix default null values and NULL value update edge case #94
Fix default null values and NULL value update edge case #94
Conversation
2d9bf95
to
99b0c6c
Compare
if ('text' === $field->sqlite_data_type) { | ||
$definition .= ' DEFAULT \'\''; | ||
} else { | ||
$definition .= ' DEFAULT 0'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamziel what do you think about this solution?
Instead of rewriting update queries with COALESCE we could always set a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will allow both inserting NULL values and updating existing rows to NULL values. MySQL rejects inserting NULL values and only allows updating. I think it's fine for now, let's just create a new issue to track rejecting inserts in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR should fix an issue with WPDB support where WordPress updates meta_value to |
Released v2.1.9 with this patch 👍 |
This PR allows SQL to set
DEFAULT NULL
which currently isn't supported because the code is built asDEFAULT
(empty value instead of NULL).It also adds support for updating a field to
NULL
that isNOT NULL
and doesn't have aDEFAULT
value.The result of the update should be an empty value ('' for text and 0 for numbers).
Testing instructions