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: Add a way to create ranges from parameters. #3650

Closed
2 tasks done
finalclass opened this issue Mar 7, 2024 · 2 comments · Fixed by #3748
Closed
2 tasks done

Feature: Add a way to create ranges from parameters. #3650

finalclass opened this issue Mar 7, 2024 · 2 comments · Fixed by #3748
Assignees
Labels
feature New feature or request topic:surrealql This is related to the SurrealQL query language

Comments

@finalclass
Copy link

Describe the bug

I want to use range query with variables but there is no way to do that.

Steps to reproduce

dg/test> create item:ulid() set index = 12
[
    {
        id: item:01HGE6SKP0YM6X1PT0QTSKW6PD,
        index: 12
    }
]

dg/test> create item:ulid() set index = 22;
[
    {
        id: item:01HGE6SPXM4Y7007SP7XX1Q0CK,
        index: 22
    }
]

dg/test> select * from item:01HGE6SKP0YM6X1PT0QTSKW6PD..;
[
    {
        id: item:01HGE6SKP0YM6X1PT0QTSKW6PD,
        index: 12
    },
    {
        id: item:01HGE6SPXM4Y7007SP7XX1Q0CK,
        index: 22
    }
]

dg/test> let $seq="01HGE6SKP0YM6X1PT0QTSKW6PD";
[]
dg/test> select * from item:$seq; --< Parse error: Failed to parse query at line 1 column 19 expected one of WITH, WHERE, SPLIT, GROUP, ORDER, LIMIT, START, FETCH, VERSION, TIMEOUT, PARELLEL, or EXPLAIN
  |
1 | select * from item:$seq;

dg/test> select * from type::thing("item", $seq)..; --< Parse error: Failed to parse query at line 1 column 41 expected an identifier
  |
1 | select * from type::thing("item", $seq)..;
  |

Expected behaviour

select * from type::thing("item", $seq)..; does not produce a parse error

SurrealDB version

1.2.1

Contact Details

s@finalclass.net

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
@finalclass finalclass added bug Something isn't working triage This issue is new labels Mar 7, 2024
@DelSkayn DelSkayn self-assigned this Mar 7, 2024
@DelSkayn
Copy link
Member

DelSkayn commented Mar 7, 2024

This is indeed invalid syntax. There doesn't seem to be, currently, a way to create ranges from params. I agree that this would probably worth while to add but I am not sure if select * from type::thing("item", $seq)..; would be the right syntax for this feature. I think implementing type::range would be a better way to support this requirement.

@DelSkayn DelSkayn added topic:surrealql This is related to the SurrealQL query language and removed triage This issue is new labels Mar 22, 2024
@DelSkayn DelSkayn changed the title Bug: Parametrized record range query (range query) - parsing error Feature: Add a way to create ranges from parameters. Mar 22, 2024
@DelSkayn DelSkayn added feature New feature or request and removed bug Something isn't working labels Mar 22, 2024
@finalclass
Copy link
Author

Nice! Thanks

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:surrealql This is related to the SurrealQL query language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants