WPDB: Allow queries to reference tables in the dbname.tablename format, and allow table names to contain any valid character, rather than just ASCII.

Props pento, willstedt for the initial patch.

See #32090.



git-svn-id: https://develop.svn.wordpress.org/trunk@32368 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2015-05-06 05:00:39 +00:00
parent 8737968ac2
commit 923c6c981b
2 changed files with 18 additions and 9 deletions

View File

@@ -526,6 +526,7 @@ class Tests_DB extends WP_UnitTestCase {
*/
function data_get_table_from_query() {
$table = 'a_test_table_name';
$db_table = '`a_test_db`.`another_test_table`';
$queries = array(
// Basic
@@ -628,8 +629,13 @@ class Tests_DB extends WP_UnitTestCase {
"SHOW INDEX FROM $table",
);
foreach ( $queries as &$query ) {
$query = array( $query, $table );
$querycount = count( $queries );
for ( $ii = 0; $ii < $querycount; $ii++ ) {
$db_query = str_replace( $table, $db_table, $queries[ $ii ] );
$expected_db_table = str_replace( '`', '', $db_table );
$queries[ $ii ] = array( $queries[ $ii ], $table );
$queries[] = array( $db_query, $expected_db_table );
}
return $queries;
}