Krinkle has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/367638 )
Change subject: rdbms: Increase coverage for Database::selectSQLText()
......................................................................
rdbms: Increase coverage for Database::selectSQLText()
* Add case for `$tables[0] == ' '`.
* Add case for `$tables == ''`.
* Add case for 'DISTINCT' option.
* Add case for 'FOR UPDATE' option.
* Add case for 'LOCK IN SHARE MODE' option.
* Add case for 'EXPLAIN' option.
Change-Id: I4a5f4754bc30d31ec35a085f39321fd358b6aa49
---
M tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
1 file changed, 41 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/38/367638/1
diff --git a/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
b/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
index 7e9494c..f519772 100644
--- a/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
+++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseSQLTest.php
@@ -61,6 +61,23 @@
],
[
[
+ // 'tables' with space prepended
indicates pre-escaped table name
+ 'tables' => ' table LEFT JOIN table2',
+ 'fields' => [ 'field' ],
+ 'conds' => [ 'field' => 'text' ],
+ ],
+ "SELECT field FROM table LEFT JOIN table2
WHERE field = 'text'"
+ ],
+ [
+ [
+ // Empty 'tables' is allowed
+ 'tables' => '',
+ 'fields' => [ 'SPECIAL_QUERY()' ],
+ ],
+ "SELECT SPECIAL_QUERY()"
+ ],
+ [
+ [
'tables' => 'table',
'fields' => [ 'field', 'alias' =>
'field2' ],
'conds' => [ 'alias' => 'text' ],
@@ -134,6 +151,30 @@
"FROM table " .
"WHERE alias IN ('1','2','3','4')"
],
+ [
+ [
+ 'tables' => 'table',
+ 'fields' => [ 'field' ],
+ 'options' => [ 'DISTINCT', 'LOCK IN
SHARE MODE' ],
+ ],
+ "SELECT DISTINCT field FROM table LOCK IN
SHARE MODE"
+ ],
+ [
+ [
+ 'tables' => 'table',
+ 'fields' => [ 'field' ],
+ 'options' => [ 'EXPLAIN' => true ],
+ ],
+ 'EXPLAIN SELECT field FROM table'
+ ],
+ [
+ [
+ 'tables' => 'table',
+ 'fields' => [ 'field' ],
+ 'options' => [ 'FOR UPDATE' ],
+ ],
+ "SELECT field FROM table FOR UPDATE"
+ ],
];
}
--
To view, visit https://gerrit.wikimedia.org/r/367638
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a5f4754bc30d31ec35a085f39321fd358b6aa49
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits