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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Raise an error when query parameters are missing #3259

Open
2 tasks done
M1N0RM1N3R opened this issue Jan 4, 2024 · 2 comments
Open
2 tasks done

Feature: Raise an error when query parameters are missing #3259

M1N0RM1N3R opened this issue Jan 4, 2024 · 2 comments
Labels
feature New feature or request topic:surrealql This is related to the SurrealQL query language triage This issue is new

Comments

@M1N0RM1N3R
Copy link

Is your feature request related to a problem?

To be frank, this one is related to my own ineptitude. 馃拃
I parameterize stuff like table names when working with my little Pydantic-based abstraction over surrealdb.py, for example:

SELECT * FROM type::table($tbl) WHERE user.id == $user_id AND timestamp > $timestamp

When I tried to use this query before, there was a parameter missing--the table name to search in ($tbl)--it defaulted to null and so it tried to search a non-existent table (NULL per my experimentation in Surrealist) so it returned nothing. It took me longer than I care to admit rummaging through log files to catch that bug.

Describe the solution

This one should be fairly simple: just make it so that an error is raised when there's a parameter declared in the query string, but no value--null or otherwise--is provided for it.

Alternative methods

You could implement this at the application layer by scanning the query string with a regex pattern like \$(\w*) and then checking if a value is provided for each param name found.

SurrealDB version

1.0.0+20230913.54aedcd for linux on x86_64

Contact Details

@m1n3r_spl on Discord

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
@M1N0RM1N3R M1N0RM1N3R added feature New feature or request triage This issue is new labels Jan 4, 2024
@kearfy kearfy added the topic:surrealql This is related to the SurrealQL query language label Jan 16, 2024
@prabirshrestha
Copy link

+1. Hit the same issue and was scratching my head on why the query wasn't working as expected.

In my case I was refactoring the variable name. It was able to auto refactor all references for the rust code but not parameters.

@Reapimus
Copy link

Would be better if this were to be an opt-in/out per parameter or just a warning - I'm sure many people make use of the current behaviour for optional parameters in their queries.

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 triage This issue is new
Projects
None yet
Development

No branches or pull requests

4 participants