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

Allow pretending for DDL statements #162

Conversation

matthewjumpsoffbuildings
Copy link
Contributor

@matthewjumpsoffbuildings matthewjumpsoffbuildings commented Dec 13, 2023

If the Connection is pretending, the DDL statements should not run

Since affectingStatement already handles pretending, its fine to just pass through to that method which will return 0 as normal, allowing the generated SQL to be captured

Comment on lines +169 to +171

if(count($queries))
$connection->runDdlBatch($queries);
Copy link
Collaborator

Choose a reason for hiding this comment

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

These fixes don't belong in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ye fair i merged from the other drop-all branch into this

@@ -295,6 +295,10 @@ public function statement($query, $bindings = []): bool
}

// is DDL Query
// allow pretending for DDL queries
if($this->pretending())
return $this->affectingStatement($query, $bindings) !== null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think runDdlBatch should be fixed to handle the pretending instead of forwarding it to affectingStatement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but isnt affectingStatement()s implementation of pretend is basically complete and simple and i would just end up duplicating affectingStatement() line for line, except for this range of lines

https://github.com/colopl/laravel-spanner/blob/master/src/Connection.php#L313-L323

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or is nothing in the affectingStatement method relevant?

@taka-oyama taka-oyama added the bug Something isn't working label Jan 5, 2024
@taka-oyama
Copy link
Collaborator

Fixed in #170.

@taka-oyama taka-oyama closed this Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants