[wp-trac] [WordPress Trac] #33470: wpdb class method get_table_from_query() malfunctions if table name contains a dash (-)

WordPress Trac noreply at wordpress.org
Thu Aug 20 21:45:22 UTC 2015


#33470: wpdb class method get_table_from_query() malfunctions if table name
contains a dash (-)
----------------------------------------+------------------------------
 Reporter:  dustinbolton                |       Owner:
     Type:  defect (bug)                |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Database                    |     Version:  trunk
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+------------------------------

Comment (by aaroncampbell):

 So, here's the thing with this. According to the
 [https://dev.mysql.com/doc/refman/5.7/en/identifiers.html MySQL Docs],
 unquoted table names can only contain `[0-9,a-z,A-Z$_]` (basic Latin
 letters, digits 0-9, dollar, underscore) and `U+0080 .. U+FFFF`. A hyphen-
 minus is `U+002D`, so according to the docs that needs to be quoted.
 WordPress uses unquoted table names in a lot of places, so I think it
 probably makes sense to only match accordingly.

 Having said that, in my tests on all the MySQL versions I have handy,
 hyphens seem to work just fine in table names unquoted. It looks like a
 discrepancy in their docs and actual practice.

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


More information about the wp-trac mailing list