Skip to content

Commit 9cd0349

Browse files
committed
refactor: clean up count query builder
1 parent db88bff commit 9cd0349

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/database/src/Builder/QueryBuilders/CountQueryBuilder.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,11 @@ public function toRawSql(): ImmutableString
137137

138138
public function build(mixed ...$bindings): Query
139139
{
140-
$count = $this->count;
141-
142140
if ($this->joins !== []) {
143-
$count = new CountStatement(
144-
table: $count->table,
145-
column: $count->column,
146-
where: $count->where,
147-
distinct: $count->distinct,
148-
joins: arr($this->joins)->map(fn (JoinStatement|string $join) => $join instanceof JoinStatement ? $join : new JoinStatement($join)),
149-
);
141+
$this->count->joins = arr($this->joins)
142+
->map(fn (JoinStatement|string $join) => $join instanceof JoinStatement ? $join : new JoinStatement($join));
150143
}
151144

152-
return new Query($count, [...$this->bindings, ...$bindings])->onDatabase($this->onDatabase);
145+
return new Query($this->count, [...$this->bindings, ...$bindings])->onDatabase($this->onDatabase);
153146
}
154147
}

0 commit comments

Comments
 (0)