Skip to content
New issue

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

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

Already on GitHub? # to your account

Add semicolon to each statement while dumping the database #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lucacri
Copy link

@lucacri lucacri commented Feb 7, 2024

Changes In Code

I added a check to see if the statement is ending with a semicolon. If not, it'll add it so that the .sql file generated is going to work also from the cockroach sql command

@lucacri lucacri requested a review from peterfox as a code owner February 7, 2024 20:47
@@ -33,7 +33,7 @@ public function dump(Connection $connection, $path): void
});

if ($statements !== []) {
$file .= PHP_EOL . $statements[0]['query'];
$file .= PHP_EOL . $statements[0]['query'] .(ends_with(trim($statements[0]['query']), ';') ? '' : ';');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ends_with will never work as the helper isn't installed in all applications with Laravel.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$file .= PHP_EOL . $statements[0]['query'] .(ends_with(trim($statements[0]['query']), ';') ? '' : ';');
$file .= PHP_EOL . Str::finish($statements[0]['query'], ';');

And import use Illuminate\Support\Str;

Copy link
Collaborator

@peterfox peterfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this didn't come up in development. Could you share an example file output with the problem and what version of Laravel/CockroachDB you're using?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants