[wp-trac] [WordPress Trac] #43589: WPDB Update change NULL values to acceptable values
WordPress Trac
noreply at wordpress.org
Tue Mar 20 19:43:34 UTC 2018
#43589: WPDB Update change NULL values to acceptable values
---------------------------------+-----------------------------
Reporter: dorianrd | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: trunk
Severity: normal | Keywords:
Focuses: multisite, rest-api |
---------------------------------+-----------------------------
Hello,
I'm creating a plugin in which i need to create a new SQL table, that I
connect to REST API. My table has several fields that can't be NULL and
some that can be NULL.
If i do the update via the wpdb object (cf. below), NULL fields are
updated with a NOT NULL value that I've never typed (a float that can't be
NULL become 0.00000, a date -0001-00-00, ....).
The expected behaviour would be to not update the line because the request
is not OK.
If I allow NULL values on these fields, values are NULL. It's like if
somewhere the value was changed to be accepted by the sql engine.
NB: the generated request is OK, when i access to the wpdb->last_query
value.
--------- code example ---------
global $wpdb;
$wpdb->update($table, $fields, $where, $fieldsformats, $whereformats);
where $fields = array("mynotnulldate"=> null, "mynotnullfloat" => null);
Dorian
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43589>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list