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

Bug: LET statement variables do not stay across queries in the CLI REPL #39

Closed
2 tasks done
peteole opened this issue Aug 20, 2022 · 4 comments · Fixed by #1561
Closed
2 tasks done

Bug: LET statement variables do not stay across queries in the CLI REPL #39

peteole opened this issue Aug 20, 2022 · 4 comments · Fixed by #1561
Assignees
Labels
bug Something isn't working
Milestone

Comments

@peteole
Copy link

peteole commented Aug 20, 2022

Describe the bug

The value of let statements is instantly lost once they have been executed. Running

-- Define the parameter
LET $name = "tobie";

And then

-- Use the parameter
CREATE person SET name = $name;

results in the name field not being set:

> LET $name = "tobie";
[{"time":"17.363µs","status":"OK","result":null}]
> CREATE person:3 SET name = $name;
[{"time":"116.22µs","status":"OK","result":[{"id":"person:3"}]}]

However interestingly copying both statements together into the repl works as expected.

Steps to reproduce

Run

> LET $name = "tobie";
[{"time":"17.363µs","status":"OK","result":null}]
> CREATE person:3 SET name = $name;
[{"time":"116.22µs","status":"OK","result":[{"id":"person:3"}]}]

Expected behaviour

The value is stored in the variable.

SurrealDB version

surreal 1.0.0-beta.6 for linux on x86_64

Contact Details

peteole2707@gmail.com

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
@peteole peteole added the bug Something isn't working label Aug 20, 2022
@tobiemh
Copy link
Member

tobiemh commented Aug 20, 2022

Hi @peteole thank you for this issue!

Currently the REPL opens a new connection to the database for each submitted query, and therefore all context between queries is reset.

We'll be changing this really soon so that it connects over the WebSocket connection instead, meaning that all context is kept between submitted queries.

That should then fix this issue.

@tobiemh tobiemh changed the title Bug: LET statements do not work Bug: LET statement variables do not stay across queries in the CLI REPL Aug 20, 2022
@tobiemh tobiemh self-assigned this Aug 20, 2022
@tobiemh
Copy link
Member

tobiemh commented Aug 22, 2022

This is also related to #35

@tomsseisums
Copy link

It's also the case for HTTP API, as there is no session being kept.

If you LET $name = "tobie" in one request and then, CREATE person SET name = $name; in another request, it will have the same problem.

Any comments on that @tobiemh, as if that's supposed to be supported in future or?

@tobiemh tobiemh added this to the v1.0.0-beta.9 milestone Dec 22, 2022
@rushmorem
Copy link
Collaborator

Hi @tobiemh. Kindly assign this to me.

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 a pull request may close this issue.

4 participants