Skip to content

Commit

Permalink
Merge release 3.8.0 into 4.0.x (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Jun 26, 2024
2 parents 2a6b096 + 535a70d commit 846e766
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .doctrine-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
"slug": "migrations",
"docsSlug": "doctrine-migrations",
"versions": [
{
"name": "3.9",
"branchName": "3.9.x",
"slug": "3.9",
"upcoming": true
},
{
"name": "3.8",
"branchName": "3.8.x",
"slug": "3.8",
"upcoming": true
"current": true
},
{
"name": "3.7",
"branchName": "3.7.x",
"slug": "3.7",
"current": true
"maintained": false
},
{
"name": "3.6",
Expand Down
11 changes: 10 additions & 1 deletion src/Generator/SqlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
*/
class SqlGenerator
{
private SqlFormatter|null $formatter = null;

public function __construct(
private readonly Configuration $configuration,
private readonly AbstractPlatform $platform,
Expand Down Expand Up @@ -55,7 +57,7 @@ public function generate(
$maxLength = $lineLength - 18 - 8; // max - php code length - indentation

if (strlen($query) > $maxLength) {
$query = (new SqlFormatter(new NullHighlighter()))->format($query);
$query = $this->formatQuery($query);
}
}

Expand Down Expand Up @@ -84,4 +86,11 @@ public function generate(

return implode("\n", $code);
}

private function formatQuery(string $query): string
{
$this->formatter ??= new SqlFormatter(new NullHighlighter());

return $this->formatter->format($query);
}
}

0 comments on commit 846e766

Please sign in to comment.