Skip to content

Commit e6f4675

Browse files
Merge pull request #32 from drsdre/drsdre-patch-fqdn-backslash
2 parents ef3ee17 + 0ff8a87 commit e6f4675

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

src/Models/Projection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function scopeName(Builder $query, string $projectorName): Builder
8787
{
8888
$this->projectionName = $projectorName;
8989

90-
return $query->where('projection_name', $projectorName);
90+
return $query->whereRaw('projection_name = ?', [$projectorName]);
9191
}
9292

9393
/**

src/Models/Scopes/ProjectionScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ProjectionScope implements Scope
1515
public function apply(Builder $builder, Model $model): void
1616
{
1717
if (! $this->isAbstractProjection($model)) {
18-
$builder->where('projection_name', $model::class);
18+
$builder->whereRaw('projection_name = ?', [$model::class]);
1919
}
2020
}
2121

src/Models/Traits/Projectable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function projections(
5252
$query = $this->morphToMany(Projection::class, 'projectable', 'time_series_projectables');
5353

5454
if (isset($projectionName)) {
55-
$query->where('projection_name', $projectionName);
55+
$query->whereRaw('projection_name = ?', [$projectionName]);
5656
}
5757

5858
if (isset($periods) && is_string($periods)) {

src/Projector.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,28 @@ private function parsePeriod(string $period): void
9393
*/
9494
private function findGlobalProjection(): Projection|null
9595
{
96-
return Projection::firstWhere([
97-
['projection_name', $this->projectionName],
98-
['key', $this->hasKey() ? $this->key() : null],
99-
['period', '*'],
100-
['start_date', null],
101-
]);
96+
return Projection::whereRaw('projection_name = ?', [$this->projectionName])
97+
->where([
98+
['key', $this->hasKey() ? $this->key() : null],
99+
['period', '*'],
100+
['start_date', null],
101+
])
102+
->first();
102103
}
103104

104105
/**
105106
* Finds the projection if it exists.
106107
*/
107108
private function findProjection(string $period): Projection|null
108109
{
109-
return Projection::firstWhere([
110-
['projection_name', $this->projectionName],
111-
['key', $this->hasKey() ? $this->key() : null],
112-
['period', $period],
113-
['start_date', app(TimeSeries::class)->resolveFloorDate($this->projectedModel->{$this->dateColumn}, $period)],
114-
]);
110+
return Projection::whereRaw('projection_name = ?', [$this->projectionName])
111+
->where([
112+
['key', $this->hasKey() ? $this->key() : null],
113+
['period', $period],
114+
['start_date', app(TimeSeries::class)->resolveFloorDate($this->projectedModel->{$this->dateColumn}, $period),
115+
],
116+
])
117+
->first();
115118
}
116119

117120
/**

tests/Collections/ProjectionCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function (Projection $lastProjection) {
223223
/** @test */
224224
public function it_is_formatted_to_a_time_series()
225225
{
226-
Log::factory()->create(['created_at' => today()]);
226+
Log::factory()->create(['created_at' => today(), 'updated_at' => today()]);
227227

228228
/** @var ProjectionCollection $collection */
229229
$collection = Projection::all();

0 commit comments

Comments
 (0)