Skip to content

Commit cfd3ac0

Browse files
laylatichygitbutler-client
authored andcommitted
fix(database): resolve merge conflict markers in aggregate files
1 parent 8f4c36b commit cfd3ac0

4 files changed

Lines changed: 0 additions & 603 deletions

File tree

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

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ public function count(?string $column = null): CountQueryBuilder
128128
}
129129

130130
/**
131-
<<<<<<< ours
132-
<<<<<<< ours
133131
* Executes an aggregate query and returns the sum of the given column.
134132
*
135133
* **Example**
@@ -182,116 +180,6 @@ public function min(string $column): mixed
182180
}
183181

184182
/**
185-
||||||| ancestor
186-
* Executes an aggregate query and returns the sum of the given column.
187-
*
188-
* **Example**
189-
* ```php
190-
* query(User::class)->sum('price');
191-
* ```
192-
*/
193-
public function sum(string $column): int|float
194-
{
195-
return $this->select()->onDatabase($this->onDatabase)->sum($column);
196-
}
197-
198-
/**
199-
* Executes an aggregate query and returns the average of the given column.
200-
*
201-
* **Example**
202-
* ```php
203-
* query(User::class)->avg('price');
204-
* ```
205-
*/
206-
public function avg(string $column): float
207-
{
208-
return $this->select()->onDatabase($this->onDatabase)->avg($column);
209-
}
210-
211-
/**
212-
* Executes an aggregate query and returns the maximum value of the given column.
213-
*
214-
* **Example**
215-
* ```php
216-
* query(User::class)->max('price');
217-
* ```
218-
*/
219-
public function max(string $column): mixed
220-
{
221-
return $this->select()->onDatabase($this->onDatabase)->max($column);
222-
}
223-
224-
/**
225-
* Executes an aggregate query and returns the minimum value of the given column.
226-
*
227-
* **Example**
228-
* ```php
229-
* query(User::class)->min('price');
230-
* ```
231-
*/
232-
public function min(string $column): mixed
233-
{
234-
return $this->select()->onDatabase($this->onDatabase)->min($column);
235-
}
236-
237-
/**
238-
=======
239-
>>>>>>> theirs
240-
||||||| ancestor
241-
=======
242-
* Executes an aggregate query and returns the sum of the given column.
243-
*
244-
* **Example**
245-
* ```php
246-
* query(User::class)->sum('price');
247-
* ```
248-
*/
249-
public function sum(string $column): int|float
250-
{
251-
return $this->select()->onDatabase($this->onDatabase)->sum($column);
252-
}
253-
254-
/**
255-
* Executes an aggregate query and returns the average of the given column.
256-
*
257-
* **Example**
258-
* ```php
259-
* query(User::class)->avg('price');
260-
* ```
261-
*/
262-
public function avg(string $column): float
263-
{
264-
return $this->select()->onDatabase($this->onDatabase)->avg($column);
265-
}
266-
267-
/**
268-
* Executes an aggregate query and returns the maximum value of the given column.
269-
*
270-
* **Example**
271-
* ```php
272-
* query(User::class)->max('price');
273-
* ```
274-
*/
275-
public function max(string $column): mixed
276-
{
277-
return $this->select()->onDatabase($this->onDatabase)->max($column);
278-
}
279-
280-
/**
281-
* Executes an aggregate query and returns the minimum value of the given column.
282-
*
283-
* **Example**
284-
* ```php
285-
* query(User::class)->min('price');
286-
* ```
287-
*/
288-
public function min(string $column): mixed
289-
{
290-
return $this->select()->onDatabase($this->onDatabase)->min($column);
291-
}
292-
293-
/**
294-
>>>>>>> theirs
295183
* Creates a new instance of this model without persisting it to the database.
296184
*
297185
* **Example**

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

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,8 @@
3333
use function Tempest\Container\get;
3434
use function Tempest\Database\inspect;
3535
use function Tempest\Mapper\map;
36-
<<<<<<< ours
3736
use function Tempest\Support\arr;
3837
use function Tempest\Support\str;
39-
||||||| ancestor
40-
use function Tempest\Support\arr;
41-
=======
42-
>>>>>>> theirs
4338

4439
/**
4540
* @template TModel
@@ -404,8 +399,6 @@ public function build(mixed ...$bindings): Query
404399
return new Query($select, [...$this->bindings, ...$bindings])->onDatabase($this->onDatabase);
405400
}
406401

407-
<<<<<<< ours
408-
<<<<<<< ours
409402
/**
410403
* Executes an aggregate query and returns the sum of the given column.
411404
*/
@@ -468,132 +461,6 @@ private function aggregate(AggregateFunction $function, string $column): mixed
468461
};
469462
}
470463

471-
||||||| ancestor
472-
/**
473-
* Executes an aggregate query and returns the sum of the given column.
474-
*/
475-
public function sum(string $column): int|float
476-
{
477-
return $this->aggregate(AggregateFunction::SUM, $column);
478-
}
479-
480-
/**
481-
* Executes an aggregate query and returns the average of the given column.
482-
*/
483-
public function avg(string $column): float
484-
{
485-
return (float) $this->aggregate(AggregateFunction::AVG, $column);
486-
}
487-
488-
/**
489-
* Executes an aggregate query and returns the maximum value of the given column.
490-
*/
491-
public function max(string $column): mixed
492-
{
493-
return $this->aggregate(AggregateFunction::MAX, $column);
494-
}
495-
496-
/**
497-
* Executes an aggregate query and returns the minimum value of the given column.
498-
*/
499-
public function min(string $column): mixed
500-
{
501-
return $this->aggregate(AggregateFunction::MIN, $column);
502-
}
503-
504-
private function aggregate(AggregateFunction $function, string $column): mixed
505-
{
506-
$key = strtolower($function->value);
507-
508-
$field = new FieldStatement(
509-
field: sprintf('%s(`%s`) AS `%s`', $function->value, $column, $key),
510-
);
511-
512-
$result = SelectQueryBuilder::fromQueryBuilder(
513-
$this,
514-
fields: new ImmutableArray([$field]),
515-
)->build()->fetchFirst()[$key] ?? null;
516-
517-
if ($result === null) {
518-
return match ($function) {
519-
AggregateFunction::AVG => 0.0,
520-
AggregateFunction::SUM => 0,
521-
default => null,
522-
};
523-
}
524-
525-
return match ($function) {
526-
AggregateFunction::AVG => (float) $result,
527-
AggregateFunction::SUM => str_contains((string) $result, '.') ? (float) $result : (int) $result,
528-
default => $result,
529-
};
530-
}
531-
532-
=======
533-
>>>>>>> theirs
534-
||||||| ancestor
535-
=======
536-
/**
537-
* Executes an aggregate query and returns the sum of the given column.
538-
*/
539-
public function sum(string $column): int|float
540-
{
541-
return $this->aggregate(AggregateFunction::SUM, $column);
542-
}
543-
544-
/**
545-
* Executes an aggregate query and returns the average of the given column.
546-
*/
547-
public function avg(string $column): float
548-
{
549-
return (float) $this->aggregate(AggregateFunction::AVG, $column);
550-
}
551-
552-
/**
553-
* Executes an aggregate query and returns the maximum value of the given column.
554-
*/
555-
public function max(string $column): mixed
556-
{
557-
return $this->aggregate(AggregateFunction::MAX, $column);
558-
}
559-
560-
/**
561-
* Executes an aggregate query and returns the minimum value of the given column.
562-
*/
563-
public function min(string $column): mixed
564-
{
565-
return $this->aggregate(AggregateFunction::MIN, $column);
566-
}
567-
568-
private function aggregate(AggregateFunction $function, string $column): mixed
569-
{
570-
$key = strtolower($function->value);
571-
572-
$field = new FieldStatement(
573-
field: sprintf('%s(`%s`) AS `%s`', $function->value, $column, $key),
574-
);
575-
576-
$result = SelectQueryBuilder::fromQueryBuilder(
577-
$this,
578-
fields: new ImmutableArray([$field]),
579-
)->build()->fetchFirst()[$key] ?? null;
580-
581-
if ($result === null) {
582-
return match ($function) {
583-
AggregateFunction::AVG => 0.0,
584-
AggregateFunction::SUM => 0,
585-
default => null,
586-
};
587-
}
588-
589-
return match ($function) {
590-
AggregateFunction::AVG => (float) $result,
591-
AggregateFunction::SUM => str_contains((string) $result, '.') ? (float) $result : (int) $result,
592-
default => $result,
593-
};
594-
}
595-
596-
>>>>>>> theirs
597464
private function clone(): self
598465
{
599466
return clone $this;

packages/database/src/IsDatabaseModel.php

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public static function count(): CountQueryBuilder
8585
}
8686

8787
/**
88-
<<<<<<< ours
89-
<<<<<<< ours
9088
* Executes an aggregate query and returns the sum of the given column.
9189
*/
9290
public static function sum(string $column): int|float
@@ -119,76 +117,6 @@ public static function min(string $column): mixed
119117
}
120118

121119
/**
122-
||||||| ancestor
123-
* Executes an aggregate query and returns the sum of the given column.
124-
*/
125-
public static function sum(string $column): int|float
126-
{
127-
return self::queryBuilder()->sum($column);
128-
}
129-
130-
/**
131-
* Executes an aggregate query and returns the average of the given column.
132-
*/
133-
public static function avg(string $column): float
134-
{
135-
return self::queryBuilder()->avg($column);
136-
}
137-
138-
/**
139-
* Executes an aggregate query and returns the maximum value of the given column.
140-
*/
141-
public static function max(string $column): mixed
142-
{
143-
return self::queryBuilder()->max($column);
144-
}
145-
146-
/**
147-
* Executes an aggregate query and returns the minimum value of the given column.
148-
*/
149-
public static function min(string $column): mixed
150-
{
151-
return self::queryBuilder()->min($column);
152-
}
153-
154-
/**
155-
=======
156-
>>>>>>> theirs
157-
||||||| ancestor
158-
=======
159-
* Executes an aggregate query and returns the sum of the given column.
160-
*/
161-
public static function sum(string $column): int|float
162-
{
163-
return self::queryBuilder()->sum($column);
164-
}
165-
166-
/**
167-
* Executes an aggregate query and returns the average of the given column.
168-
*/
169-
public static function avg(string $column): float
170-
{
171-
return self::queryBuilder()->avg($column);
172-
}
173-
174-
/**
175-
* Executes an aggregate query and returns the maximum value of the given column.
176-
*/
177-
public static function max(string $column): mixed
178-
{
179-
return self::queryBuilder()->max($column);
180-
}
181-
182-
/**
183-
* Executes an aggregate query and returns the minimum value of the given column.
184-
*/
185-
public static function min(string $column): mixed
186-
{
187-
return self::queryBuilder()->min($column);
188-
}
189-
190-
/**
191-
>>>>>>> theirs
192120
* Creates a new instance of this model without persisting it to the database.
193121
*/
194122
public static function new(mixed ...$params): self

0 commit comments

Comments
 (0)