Skip to content

Commit a5278f3

Browse files
committed
Merge branch 'hotfix/fix-wherebetween'
2 parents b49e122 + e904494 commit a5278f3

File tree

9 files changed

+132
-51
lines changed

9 files changed

+132
-51
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.23] - 13 Feb 2018
8+
### Fixed
9+
- whereBetween and value bindings parsing.
10+
711
## [0.2.22] - 10 Feb 2018
812
### Fixed
913
- Laravel 5.5 dependencies.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"fzaninotto/faker": "~1.4",
1919
"mockery/mockery": "0.9.*",
2020
"orchestra/database": "3.6.x-dev@dev",
21-
"orchestra/testbench-browser-kit": "3.6.x-dev@dev",
21+
"orchestra/testbench-browser-kit": "^3.6",
2222
"orchestra/testbench-dusk": "3.6.x-dev@dev",
2323
"orchestra/testbench": "^3.6",
2424
"php-coveralls/php-coveralls" : "*",

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
convertWarningsToExceptions="true"
1010
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
1111
processIsolation="false"
12-
stopOnFailure="false"
12+
stopOnFailure="true"
1313
syntaxCheck="false"
1414
>
1515
<testsuites>

src/CacheKey.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function getQueryColumns(array $columns) : string
9090

9191
protected function getTypeClause($where) : string
9292
{
93-
$type =in_array($where['type'], ['In', 'Null', 'NotNull'])
93+
$type =in_array($where['type'], ['In', 'Null', 'NotNull', 'between'])
9494
? strtolower($where['type'])
9595
: strtolower($where['operator']);
9696

@@ -99,9 +99,19 @@ protected function getTypeClause($where) : string
9999

100100
protected function getValuesClause(array $where = null) : string
101101
{
102-
return is_array(array_get($where, 'values'))
103-
? '_' . implode('_', $where['values'])
102+
if (in_array($where['type'], ['NotNull'])) {
103+
return '';
104+
}
105+
106+
$values = is_array(array_get($where, 'values'))
107+
? implode('_', $where['values'])
104108
: '';
109+
110+
if (! $values && $this->query->bindings['where'] ?? false) {
111+
$values = implode('_', $this->query->bindings['where']);
112+
}
113+
114+
return '_' . $values;
105115
}
106116

107117
protected function getWhereClauses(array $wheres = []) : string
@@ -152,7 +162,6 @@ protected function getOtherClauses(array $where, string $carry = null) : string
152162
}
153163

154164
$value = $this->getTypeClause($where);
155-
$value .= "_" . array_get($where, 'value');
156165
$value .= $this->getValuesClause($where);
157166

158167
return "{$carry}-{$where['column']}_{$value}";

tests/Fixtures/Book.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66

77
class Book extends CachedModel
88
{
9+
protected $casts = [
10+
'price' => 'float',
11+
];
912
protected $dates = [
1013
'published_at',
1114
];
1215
protected $fillable = [
1316
'description',
1417
'published_at',
1518
'title',
19+
'price',
1620
];
1721

1822
public function author() : BelongsTo

0 commit comments

Comments
 (0)