Skip to content

Conversation

@MorrisJobke
Copy link
Member

On Oracle the unquoted identifiers are upper cased:

Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing 'SELECT MAX(id) FROM "oc_calendarobjects"':

ORA-00904: "ID": ungültige ID

public function countFiles($numericId, OutputInterface $output) {
$queryBuilder = $this->connection->getQueryBuilder();
$queryBuilder->select($queryBuilder->createFunction('count(fileid)'))
$queryBuilder->select($queryBuilder->createFunction('count(' . $queryBuilder->getColumnName('fileid') . ')'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uppercase the function name?

$query->select($query->createFunction('COUNT(Distinct ' . $query->getColumnName('uid') . ')'))
->from('preferences', 'p')
->innerJoin('p', 'group_user', 'g', 'p.userid = g.uid')
->innerJoin('p', 'group_user', 'g', 'p.`userid` = g.`uid`')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$query->expr()->eq('p.userid', 'g.uid')


$query = $this->dbConn->getQueryBuilder();
$query->select($query->createFunction('COUNT(Distinct uid)'))
$query->select($query->createFunction('COUNT(Distinct ' . $query->getColumnName('uid') . ')'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uppercase DISTINCT

public function countDisabledUsersOfGroups(array $groups): int {
$queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$queryBuilder->select($queryBuilder->createFunction('COUNT(Distinct uid)'))
$queryBuilder->select($queryBuilder->createFunction('COUNT(Distinct ' . $queryBuilder->getColumnName('uid') . ')'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uppercase DISTINCT

$queryBuilder->select($queryBuilder->createFunction('COUNT(Distinct uid)'))
$queryBuilder->select($queryBuilder->createFunction('COUNT(Distinct ' . $queryBuilder->getColumnName('uid') . ')'))
->from('preferences', 'p')
->innerJoin('p', 'group_user', 'g', 'p.userid = g.uid')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$query->expr()->eq('p.userid', 'g.uid')

@MorrisJobke MorrisJobke force-pushed the fix/noid/proper-column-name-escaping branch from f48fc25 to b458ed9 Compare October 16, 2018 13:24
@MorrisJobke
Copy link
Member Author

@nickvergessen Addressed your comments.

@nickvergessen nickvergessen requested review from ChristophWurst and georgehrke and removed request for ChristophWurst October 16, 2018 13:32
@nickvergessen nickvergessen added bug 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Oct 16, 2018
@MorrisJobke MorrisJobke merged commit b88ab75 into master Oct 16, 2018
@MorrisJobke MorrisJobke deleted the fix/noid/proper-column-name-escaping branch October 16, 2018 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants