mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Prevent query error when use subquery
Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
parent
a7c0868a4c
commit
afe5b6dd8a
4 changed files with 12 additions and 9 deletions
|
|
@ -4387,10 +4387,6 @@
|
|||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="lib/private/Repair/RemoveLinkShares.php">
|
||||
<ImplicitToStringCast occurrences="2">
|
||||
<code>$query->createFunction('(' . $subQuery->getSQL() . ')')</code>
|
||||
<code>$subQuery->createFunction('(' . $subSubQuery->getSQL() . ')')</code>
|
||||
</ImplicitToStringCast>
|
||||
<InvalidPropertyAssignmentValue occurrences="1">
|
||||
<code>$this->userToNotify</code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
|
|
|
|||
|
|
@ -694,7 +694,7 @@ class QueryBuilder implements IQueryBuilder {
|
|||
* ->from('users', 'u')
|
||||
* </code>
|
||||
*
|
||||
* @param string $from The table.
|
||||
* @param string|IQueryFunction $from The table.
|
||||
* @param string|null $alias The alias of the table.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
|
|
@ -1303,7 +1303,7 @@ class QueryBuilder implements IQueryBuilder {
|
|||
/**
|
||||
* Returns the table name quoted and with database prefix as needed by the implementation
|
||||
*
|
||||
* @param string $table
|
||||
* @param string|IQueryFunction $table
|
||||
* @return string
|
||||
*/
|
||||
public function getTableName($table) {
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ interface IQueryBuilder {
|
|||
* ->from('users', 'u')
|
||||
* </code>
|
||||
*
|
||||
* @param string $from The table.
|
||||
* @param string|IQueryFunction $from The table.
|
||||
* @param string|null $alias The alias of the table.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
|
|
@ -994,7 +994,7 @@ interface IQueryBuilder {
|
|||
/**
|
||||
* Returns the table name quoted and with database prefix as needed by the implementation
|
||||
*
|
||||
* @param string $table
|
||||
* @param string|IQueryFunction $table
|
||||
* @return string
|
||||
* @since 9.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1204,6 +1204,9 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function dataGetTableName() {
|
||||
$config = $this->createMock(SystemConfig::class);
|
||||
$logger = $this->createMock(ILogger::class);
|
||||
$qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
|
||||
return [
|
||||
['*PREFIX*table', null, '`*PREFIX*table`'],
|
||||
['*PREFIX*table', true, '`*PREFIX*table`'],
|
||||
|
|
@ -1212,13 +1215,17 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
['table', null, '`*PREFIX*table`'],
|
||||
['table', true, '`*PREFIX*table`'],
|
||||
['table', false, '`table`'],
|
||||
|
||||
[$qb->createFunction('(' . $qb->select('*')->from('table')->getSQL() . ')'), null, '(SELECT * FROM `*PREFIX*table`)'],
|
||||
[$qb->createFunction('(' . $qb->select('*')->from('table')->getSQL() . ')'), true, '(SELECT * FROM `*PREFIX*table`)'],
|
||||
[$qb->createFunction('(' . $qb->select('*')->from('table')->getSQL() . ')'), false, '(SELECT * FROM `*PREFIX*table`)'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetTableName
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string|IQueryFunction $tableName
|
||||
* @param bool $automatic
|
||||
* @param string $expected
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue