[wp-trac] [WordPress Trac] #22196: add $wpdb->upsert function

WordPress Trac noreply at wordpress.org
Thu Jul 20 09:07:51 UTC 2017


#22196: add $wpdb->upsert function
-------------------------------------------------+-------------------------
 Reporter:  thomask                              |       Owner:
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  Future
Component:  Database                             |  Release
 Severity:  normal                               |     Version:  3.4.2
 Keywords:  has-patch needs-testing needs-       |  Resolution:  maybelater
  refresh needs-unit-tests                       |     Focuses:
-------------------------------------------------+-------------------------
Changes (by donpark):

 * status:  reopened => closed
 * resolution:   => maybelater


Comment:

 Details on UPSERT problem @pento mentioned can be found here:
 https://stackoverflow.com/questions/16377932/mysql-behavior-of-on-
 duplicate-key-update-for-multiple-unique-fields
 Duplicate keys are matched with OR, not AND, which makes no sense to me.
 Undefined behavior stems for undefined order of duplicate key matching
 rows.

 In short, UPSERT on MySQL needs to be used with care. Frankly I think this
 may be too much to ask for from typical WP hackers, even with flashing
 warning message.

 Changing status to maybelater again to be reconsidered when and if demand
 for upsert warrants reconsideration.

 Thx for the quick response @pento.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/22196#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list