-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the defined func()->count() instead of manual counting #11942
Conversation
@@ -72,7 +72,8 @@ public function subtract($x, $y) { | |||
return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); | |||
} | |||
|
|||
public function count($input) { | |||
return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($input) . ')'); | |||
public function count($count, $alias = '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't alias work by just using selectAlias($qb->func()->count(...), 'alias')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, i added it here because its done quite often
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having it here doesn't make sense to me though, since for the caller it's not any easier (the only difference is where you place the )
) and it's duplicating code/functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this here. It also reduces function nesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good 👍
@icewind1991 @rullzer Any comments on this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with me
Yay PHPunit tests fail 😢 I should have checked that earlier |
Ah - disk was just full -> let's do another round: https://drone.nextcloud.com/nextcloud/server/12482 |
This causes the same "Disk is full" errors 😨 |
strange, let me investigate |
08ee437
to
7365078
Compare
$qb->createFunction('COUNT(' . $qb->getColumnName('c.id') . ')'), | ||
'num_ids' | ||
) | ||
->addSelect($qb->func()->count('c.id', 'num_ids')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MorrisJobke the problem was select
here instead of addSelect
which caused a lot of spam with missing index fileId across tests
Still this one:
|
fixed |
7365078
to
82fb91b
Compare
Fails on Postgres https://drone.nextcloud.com/nextcloud/server/12537/167:
|
Signed-off-by: Joas Schilling <coding@schilljs.com>
82fb91b
to
bb352fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Now there are only 2 "functions" left which are both called twice and don't have a wrapper:
Not sure if it's worth the effort.