[wp-trac] [WordPress Trac] #30257: wpdb::get_var() returns NULL for existing values that are empty strings

WordPress Trac noreply at wordpress.org
Wed Nov 5 08:18:33 UTC 2014


#30257: wpdb::get_var() returns NULL for existing values that are empty strings
-------------------------+-----------------------------
 Reporter:  tyxla        |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Database     |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 I have noticed that using $wpdb->get_var() returns `NULL` in both of these
 cases:

 * When there is no such value in the database
 * When there is a value, but it is an empty string

 This appears to be intended and is explicitly defined on the following
 line: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/wp-
 db.php#L1870

 In my opinion it does not make sense for an empty string to be represented
 as `NULL`, as there is a distinguishable difference between NULL and empty
 string.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30257>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list