-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add savepoint API #433
base: master
Are you sure you want to change the base?
Add savepoint API #433
Conversation
tests/test_async_tx.py
Outdated
with self.assertRaisesRegex( | ||
edgedb.InterfaceError, "savepoint.*already exists" | ||
): | ||
await tx.declare_savepoint("sp1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is contrary to server savepoint semantics, masking an earlier savepoint is allowed:
edgedb> start transaction;
OK: START TRANSACTION
edgedb[tx]> declare savepoint sp1;
OK: DECLARE SAVEPOINT
edgedb[tx]> declare savepoint sp1;
OK: DECLARE SAVEPOINT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This releases previous savepoint with that name, right?
Not it doesn't. It creates a nested one with that name. And then you have to release twice.
So releasing the one that was created first should release inner, to have correct semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think Paul is right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three questions:
- Why do we skip context API:
with tx.declare_savepoint("name")
entirely? - We should allow skipping name argument and generate something unique (e.g. uuid). Actually while we have variables in python (I mean
sp_name = conn.declare_savepoint()
) names are useless, will only provoke unexpected conflicts. - Do we need
declare_
part?x = tx.savepoint()
is nice, no? (we already do that with transactions by skippingstart
part)
Context API fits in pretty nicely, even with rollback (since rollback and release aren't mutually exclusive):
with tx.savepoint() as sp:
# do something
if was_already_applied:
sp.rollback()
It can be added later, but is pretty uncontroversial I think.
tests/test_async_tx.py
Outdated
with self.assertRaisesRegex( | ||
edgedb.InterfaceError, "savepoint.*already exists" | ||
): | ||
await tx.declare_savepoint("sp1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This releases previous savepoint with that name, right?
Not it doesn't. It creates a nested one with that name. And then you have to release twice.
So releasing the one that was created first should release inner, to have correct semantics.
+1
Yes, please, it should be |
Pushed a fix to rename
Let's add later 😏 |
Hi all, any updates on this? |
Sorry, not yet. But we'll put time into the Python binding very soon! |
Please see tests for use case.
Fixes #407