[wp-trac] [WordPress Trac] #31679: dbDelta generates wrong SQL on ALTER TABLE with fields containing hyphens in name
WordPress Trac
noreply at wordpress.org
Wed Mar 18 09:16:02 UTC 2015
#31679: dbDelta generates wrong SQL on ALTER TABLE with fields containing hyphens
in name
--------------------------+-----------------------------
Reporter: fulippo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 4.1.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Upgrading a table using dbDelta a wrong SQL statement is generated when
existing table's names contain hyphens.
Example of wrong SQL statement generated by dbDelta:
{{{
ALTER TABLE wp_stores CHANGE COLUMN _store-lng `_store-lng` text NULL
}}}
This is because the result for the query
{{{ $tablefields = $wpdb->get_results("DESCRIBE {$table};"); }}}
contains column names without backticks causing the SQL query to fail.
Since there is no way to filter column names it is impossible to upgrade
tables.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31679>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list