Skip to content

Commit e407f13

Browse files
committed
Perform more robust paramter binding.
1 parent a0a6fc8 commit e407f13

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

Diff for: phpunit.xml

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
<env name="DB_CONNECTION" value="sqlite"/>
3737
<env name="DB_DATABASE" value=":memory:"/>
3838
<env name="REDIS_HOST" value="192.168.10.10"/>
39+
<env name="PGSQL_HOST" value="192.168.10.10"/>
3940
</php>
4041
</phpunit>

Diff for: phpunit.xml.dist

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="true"
12+
>
13+
<testsuites>
14+
<testsuite name="Setup">
15+
<directory>./tests/AlwaysRunFirstTest.php</directory>
16+
</testsuite>
17+
<testsuite name="Feature">
18+
<directory suffix="Test.php">./tests/Feature</directory>
19+
</testsuite>
20+
<testsuite name="Integration">
21+
<directory suffix="Test.php">./tests/Integration</directory>
22+
</testsuite>
23+
</testsuites>
24+
<filter>
25+
<whitelist processUncoveredFilesFromWhitelist="false">
26+
<directory suffix=".php">./src</directory>
27+
</whitelist>
28+
</filter>
29+
<php>
30+
<env name="APP_KEY" value="base64:Xgs1LQt1GdVHhD6qyYCXnyq61DE3UKqJ5k2SJc+Nw2g="/>
31+
<env name="APP_ENV" value="testing"/>
32+
<env name="APP_URL" value="http://localhost"/>
33+
<env name="CACHE_DRIVER" value="redis"/>
34+
<env name="SESSION_DRIVER" value="array"/>
35+
<env name="QUEUE_DRIVER" value="sync"/>
36+
<env name="DB_CONNECTION" value="sqlite"/>
37+
<env name="DB_DATABASE" value=":memory:"/>
38+
<env name="REDIS_HOST" value="127.0.0.1"/>
39+
<env name="PGSQL_HOST" value="127.0.0.1"/>
40+
</php>
41+
</phpunit>

Diff for: src/CacheKey.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ protected function getInAndNotInClauses(array $where) : string
229229
$subquery = $this->getValuesFromWhere($where);
230230
$values = collect($this->query->bindings["where"][$this->currentBinding] ?? []);
231231
$this->currentBinding += count($where["values"]);
232-
$subquery = collect(vsprintf(str_replace("?", "%s", $subquery), $values->toArray()));
232+
$subquery = preg_replace('/\?(?=(?:[^"]*"[^"]*")*[^"]*\Z)/m', "_??_", $subquery);
233+
$subquery = collect(vsprintf(str_replace("_??_", "%s", $subquery), $values->toArray()));
233234
$values = $this->recursiveImplode($subquery->toArray(), "_");
234235

235236
return "-{$where["column"]}_{$type}{$values}";

Diff for: tests/Integration/CachedBuilder/WhereJsonContainsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protected function getEnvironmentSetUp($app)
1414
parent::getEnvironmentSetUp($app);
1515

1616
$app['config']->set('database.default', 'pgsql');
17-
$app['config']->set('database.connections.pgsql.host', "127.0.0.1");
17+
$app['config']->set('database.connections.pgsql.host', env("PGSQL_HOST", "127.0.0.1"));
1818
$app['config']->set('database.connections.pgsql.database', "testing");
1919
$app['config']->set('database.connections.pgsql.username', "homestead");
2020
$app['config']->set('database.connections.pgsql.password', "secret");

Diff for: tests/database/baseline.sqlite

-32 KB
Binary file not shown.

Diff for: tests/database/testing.sqlite

-32 KB
Binary file not shown.

0 commit comments

Comments
 (0)