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

Documentation: Commit's or Begin's Documentation should additionally mention RETURN's extra behaviour in Transactions. #1252

Open
2 tasks done
Laifsyn opened this issue Mar 24, 2025 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@Laifsyn
Copy link

Laifsyn commented Mar 24, 2025

Description

I had been running on circles about why I would suddenly only have 1 statement returned when testing in the sdk when in the surrealist test I would get more than a single statement.

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Laifsyn Laifsyn added the documentation Improvements or additions to documentation label Mar 24, 2025
@Dhghomon
Copy link
Contributor

Hi there,

Adding RETURN behaviour to those two pages is a good idea. Can you give an example though of the different behaviour you are seeing in an SDK vs. Surrealist?

@Laifsyn
Copy link
Author

Laifsyn commented Apr 8, 2025

-- Possible common cases people will find:
-- Read from some record, and store the content
let $from_foo = select id from foo:1;
-- Use the stored variable
select name from baz where some_field == $from_foo.other_field;
// Hypothethical case:
let response = db.query("let $from_foo = select id from foo:1;select name from baz where some_field == $from_foo.other_field;").await?;
let my_type : Vec<MyType> = response.take(1)?;

Everything is fine so far, but once you use it in a transaction

BEGIN;
let $from_foo = select id from foo:1;
select name from baz where some_field == $from_foo.other_field;
return $from_foo;
create baz:2; -- Won't execute as per Return's documentation
-- THROW "Don't Commit"; -- Throws won't cancel the transaction either
COMMIT;

Not getting executed is documented on the RETURN statement, However, not having a single mention inside BEGIN's documentation (or transactions related statements) could cause confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants