From 04095db141680ab2743d8517addb66e9369d759b Mon Sep 17 00:00:00 2001 From: Andrew Minion Date: Wed, 31 Jul 2024 16:01:51 -0500 Subject: [PATCH 1/6] flatten bindings for Telescope See also https://github.com/laravel/telescope/pull/1499 --- src/Services/FileMakerConnection.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index 5b3e627..e8e1159 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -764,7 +764,14 @@ protected function logFMQuery($method, $url, $params, $start) $sql .= "\nData: " . json_encode($params, JSON_PRETTY_PRINT); } - $this->event(new QueryExecuted($sql, Arr::get($params, 'query', []), $this->getElapsedTime($start), $this)); + $this->event(new QueryExecuted( + $sql, + collect(data_get($params, 'query', []))->map( + fn (array $binding) => array_keys($binding)[0] . ': ' . array_values($binding)[0] + )->all(), + $this->getElapsedTime($start), + $this, + )); } protected function getSqlCommandType($method, $url) From d1338a7658249cb0042fc9051e462fc9750bb057 Mon Sep 17 00:00:00 2001 From: Andrew Minion Date: Fri, 30 Aug 2024 15:11:14 -0500 Subject: [PATCH 2/6] retain additional field data --- src/Services/FileMakerConnection.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index e8e1159..59d1fc2 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -767,7 +767,9 @@ protected function logFMQuery($method, $url, $params, $start) $this->event(new QueryExecuted( $sql, collect(data_get($params, 'query', []))->map( - fn (array $binding) => array_keys($binding)[0] . ': ' . array_values($binding)[0] + fn (array $binding) => collect($binding) + ->map(fn ($value, $key) => $key . ': ' . $value) + ->join(', ') )->all(), $this->getElapsedTime($start), $this, @@ -816,7 +818,7 @@ public function setRetries($retries) protected function getDefaultQueryGrammar() { - return new FMGrammar(); + return new FMGrammar; } // public function getLayoutMetadata($layout = null) From 775e0df855b3efcce6aae746c6cc517f372d2684 Mon Sep 17 00:00:00 2001 From: Andrew Minion Date: Fri, 6 Sep 2024 09:36:23 -0500 Subject: [PATCH 3/6] remove unrelated change --- src/Services/FileMakerConnection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index 59d1fc2..46cc475 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -818,7 +818,7 @@ public function setRetries($retries) protected function getDefaultQueryGrammar() { - return new FMGrammar; + return new FMGrammar(); } // public function getLayoutMetadata($layout = null) From 5b79bb7f83a15d377d0227f50a6e304ee0adb70e Mon Sep 17 00:00:00 2001 From: Andrew Minion Date: Fri, 6 Sep 2024 14:06:51 -0500 Subject: [PATCH 4/6] flatten bindings #78 --- src/Services/FileMakerConnection.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index 46cc475..568cc32 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -767,10 +767,8 @@ protected function logFMQuery($method, $url, $params, $start) $this->event(new QueryExecuted( $sql, collect(data_get($params, 'query', []))->map( - fn (array $binding) => collect($binding) - ->map(fn ($value, $key) => $key . ': ' . $value) - ->join(', ') - )->all(), + fn (array $binding, $index) => collect($binding)->map(fn ($value, $key) => $index . ': ' . $key . ': ' . $value) + )->flatten()->all(), $this->getElapsedTime($start), $this, )); From 80fd004299a052ca4ff088f45101b8115f1a3fe5 Mon Sep 17 00:00:00 2001 From: Andrew Minion Date: Fri, 6 Sep 2024 14:50:49 -0500 Subject: [PATCH 5/6] preserve fields --- src/Services/FileMakerConnection.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index 568cc32..abc5b7d 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -766,9 +766,9 @@ protected function logFMQuery($method, $url, $params, $start) $this->event(new QueryExecuted( $sql, - collect(data_get($params, 'query', []))->map( - fn (array $binding, $index) => collect($binding)->map(fn ($value, $key) => $index . ': ' . $key . ': ' . $value) - )->flatten()->all(), + collect(data_get($params, 'query', []))->flatMap( + fn (array $binding, $index) => collect($binding)->mapWithKeys(fn ($value, $key) => [$index.': '.$key => $value]) + )->all(), $this->getElapsedTime($start), $this, )); From 6fab13aa0866aab484818b839fea9b97de8438bd Mon Sep 17 00:00:00 2001 From: David Nahodyl Date: Fri, 6 Sep 2024 15:57:20 -0400 Subject: [PATCH 6/6] moved bindings function to a variable for readability --- src/Services/FileMakerConnection.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Services/FileMakerConnection.php b/src/Services/FileMakerConnection.php index abc5b7d..abaf85d 100644 --- a/src/Services/FileMakerConnection.php +++ b/src/Services/FileMakerConnection.php @@ -764,11 +764,13 @@ protected function logFMQuery($method, $url, $params, $start) $sql .= "\nData: " . json_encode($params, JSON_PRETTY_PRINT); } + $bindings = collect(data_get($params, 'query', []))->flatMap( + fn (array $binding, $index) => collect($binding)->mapWithKeys(fn ($value, $key) => [$index . ': ' . $key => $value]) + )->all(); + $this->event(new QueryExecuted( $sql, - collect(data_get($params, 'query', []))->flatMap( - fn (array $binding, $index) => collect($binding)->mapWithKeys(fn ($value, $key) => [$index.': '.$key => $value]) - )->all(), + $bindings, $this->getElapsedTime($start), $this, )); @@ -816,7 +818,7 @@ public function setRetries($retries) protected function getDefaultQueryGrammar() { - return new FMGrammar(); + return new FMGrammar; } // public function getLayoutMetadata($layout = null)