diff --git a/src/Watchers/QueryWatcher.php b/src/Watchers/QueryWatcher.php index 534c12bb3..066dc379b 100644 --- a/src/Watchers/QueryWatcher.php +++ b/src/Watchers/QueryWatcher.php @@ -119,7 +119,11 @@ public function replaceBindings($event) protected function quoteStringBinding($event, $binding) { try { - return $event->connection->getPdo()->quote($binding); + $pdo = $event->connection->getPdo(); + + if ($pdo instanceof \PDO) { + return $pdo->quote($binding); + } } catch (\PDOException $e) { throw_if('IM001' !== $e->getCode(), $e); } diff --git a/tests/Watchers/QueryWatcherTest.php b/tests/Watchers/QueryWatcherTest.php index f60e4c4ee..3534f3bd0 100644 --- a/tests/Watchers/QueryWatcherTest.php +++ b/tests/Watchers/QueryWatcherTest.php @@ -3,6 +3,8 @@ namespace Laravel\Telescope\Tests\Watchers; use Carbon\Carbon; +use Illuminate\Database\Connection; +use Illuminate\Database\Events\QueryExecuted; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Laravel\Telescope\EntryType; @@ -101,4 +103,41 @@ public function test_query_watcher_can_prepare_named_bindings() $this->assertSame('testbench', $entry->content['connection']); } + + public function test_query_watcher_can_prepare_bindings_for_nonstandard_connections() + { + $event = new QueryExecuted(<<<'SQL' +select +Method: post +URL: https://fms.example.com/fmi/data/vLatest/databases/Database_Name/layouts/dapi_layout/_find +Data: { + "query": [ + { + "kp_iti": "=ITI0130" + } + ], + "limit": 1 +} +SQL, + ['kp_id' => '=ABC001'], + 500, + new Connection('filemaker'), + ); + + $sql = app()->make(QueryWatcher::class)->replaceBindings($event); + + $this->assertSame(<<<'SQL' +select +Method: post +URL: https://fms.example.com/fmi/data/vLatest/databases/Database_Name/layouts/dapi_layout/_find +Data: { + "query": [ + { + "kp_iti": "=ITI0130" + } + ], + "limit": 1 +} +SQL, $sql); + } }