Skip to content

Commit

Permalink
Fix raw SQL query output
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Jan 27, 2024
1 parent 9c42b54 commit 2d8214c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- Improved error handling in a previous migration.
- Made some minor optimisations to the file storage driver.

### Fixed

- Fixed a bug in which line breaks were not being replaced with spaces in raw SQL query output in the Blitz Diagnostics utility ([#611](https://github.com/putyourlightson/craft-blitz/issues/611)).

## 4.10.3 - 2024-01-13

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/DiagnosticsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,13 @@ public static function getElementQuerySql(string $elementQueryType, string $para
$elementQuery = RefreshCacheHelper::getElementQueryWithParams($elementQueryType, $params);

try {
return $elementQuery
$sql = $elementQuery
->select(['elementId' => 'elements.id'])
->createCommand()
->getRawSql();

// Return raw SQL with line breaks replaced with spaces.
return str_replace(["\r\n", "\r", "\n"], ' ', $sql);
} catch (QueryAbortedException) {
return null;
}
Expand Down

0 comments on commit 2d8214c

Please sign in to comment.