Add support for using Term as query in run_query()#2796
Draft
bakaq wants to merge 1 commit intomthom:masterfrom
Draft
Add support for using Term as query in run_query()#2796bakaq wants to merge 1 commit intomthom:masterfrom
bakaq wants to merge 1 commit intomthom:masterfrom
Conversation
0fd36da to
9227b91
Compare
Contributor
|
Anything we can do to prevent string injection would be very welcome for making Scryer an easy choice as a web native language! |
Contributor
Author
|
Converted to a draft because this will be significantly different in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces a feature that was discussed quite a bit before (#2465 (comment), #2500 (reply in thread), #2637 (comment)): using a structured
Terminstead of a wobbly string for queries. This makes it easier to procedurally generate queries, and also provides a good way to avoid injection attacks.In the way I implemented,
Machine::run_query()can now accept either (things that can be turned into) strings or aTerm. A simple example (taken from the tests):This could get even more ergonomic if we eventually make macros for creating
Terms (though I think it would have a lot of limitations on the allowed syntax). Imagine:After doing this I'm really glad we are getting rid of
parser::ast::Termin rebis-dev, because that type is a mess! However, from what I've read of the rebis-dev branch, it not existing will probably make this feature a bit harder to implement.This also serves as even more incentive to base the C embedding interface on a
Termbased API instead of on top of JSON serialization.