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

Feature: Handle functions as part of FROM clause of Live Queries #3956

Open
2 tasks done
hysuki opened this issue Apr 27, 2024 · 6 comments
Open
2 tasks done

Feature: Handle functions as part of FROM clause of Live Queries #3956

hysuki opened this issue Apr 27, 2024 · 6 comments
Assignees
Labels
feature New feature or request topic:live This is related to live queries and push notifications topic:surrealql This is related to the SurrealQL query language

Comments

@hysuki
Copy link

hysuki commented Apr 27, 2024

Original: Bug: vars parse error on ws query method when adding 'live'

Describe the bug

When I attempt to use 'live' queries with variables via the ws 'query' method, I encounter a parsing error.

Steps to reproduce

{
  "id": 2,
  "method": "query",
  "params": [
    "LIVE SELECT * FROM type::table($tb);",
    {
      "tb": "user"
    }
  ]
}
{
  "error": {
    "code": -32000,
    "message": "There was a problem with the database: Parse error: Failed to parse query at line 1 column 24 expected query to end\n  |\n1 | LIVE SELECT * FROM type::table($tb);\n  |                        ^ perhaps missing a semicolon on the previous statement?\n"
  },
  "id": 2
}

Expected behaviour

{
  "id": 2,
  "result": [
    {
      "result": "93d2e14b-3d1e-4bfd-977e-65c3d7c0c496",
      "status": "OK",
      "time": "6.815083ms"
    }
  ]
}

SurrealDB version

surrealdb-1.4.2

Contact Details

aside.hazle@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
@hysuki hysuki added bug Something isn't working triage This issue is new labels Apr 27, 2024
@emmanuel-keller
Copy link
Contributor

@phughk Not sure if this is related to parsing, livequeries, or websockets. Worth investigating

@DelSkayn
Copy link
Member

DelSkayn commented May 7, 2024

This is probably a case of somewhat confusing syntax. In live select statements the FROM clause may, currently, only contain either a table name or a parameter. A function call like type::table is not allowed.

This should probably be changed, cause the parameter currently can't really be used correctly.
A workaround for now is to change the query to something like the following:

let $tb_type = type::table($tb);
LIVE SELECT * FROM $tb_type

@DelSkayn
Copy link
Member

DelSkayn commented May 7, 2024

Maybe this bug should be more a feature request for allowing expressions in live select from clauses.

@hysuki
Copy link
Author

hysuki commented May 8, 2024

@DelSkayn It's perfectly understood

Do I need to create a new issue that feature request about this?
or will add feature request label this?

@phughk
Copy link
Contributor

phughk commented May 13, 2024

Hi @hysuki , this was recently resolved and should be available in #3946 and the query parsing was resolved in an earlier fix.
Please can you confirm if this is still the case for you after upgrading to 1.5.0-beta1

@phughk phughk self-assigned this May 13, 2024
@phughk phughk added topic:surrealql This is related to the SurrealQL query language topic:live This is related to live queries and push notifications question Further information is requested and removed triage This issue is new labels May 13, 2024
@phughk phughk changed the title Bug: vars parse error on ws query method when adding 'live' Feature: Handle functions as part of FROM clause of Live Queries May 13, 2024
@phughk phughk added feature New feature or request and removed bug Something isn't working question Further information is requested labels May 13, 2024
@phughk
Copy link
Contributor

phughk commented May 13, 2024

@DelSkayn kindly explained the issue in more detail - I hadn't noticed it was a function call, which would be new syntax to support. I have changed the ticket from a bug to a feature, as this would have to be added. Thank you both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request topic:live This is related to live queries and push notifications topic:surrealql This is related to the SurrealQL query language
Projects
None yet
Development

No branches or pull requests

4 participants