Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 3.8.0 into 4.0.x #1439

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}