-
Notifications
You must be signed in to change notification settings - Fork 1
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
Query builder and driver #3
Conversation
I tried my best at keeping the nomenclature from the SELECT statement. This proof of concept (poc) only includes ``` SELECT * FROM @table [WHERE @condition] [ORDER BY @field ASC|DESC] @condition := @condition AND @condition | @field IS @var | @var IS @field ``` but I tried to easily enable the completion with any binary operator. Also, I guess it would be easy to add unary operators. To get an idea of what is currently missing check out SurrealDB official documentation: - [SELECT statement]( https://surrealdb.com/docs/surrealql/statements/select ) - [Surreal operators]( https://surrealdb.com/docs/surrealql/operators ) - [Record ranges]( https://surrealdb.com/docs/surrealql/datamodel/ids ) Finally I supposed that we don't need to take care of the types at this layer of the library because as far as I know, surrealdb.go library already has the `Var` abstraction I introduced hereby.
add layer on top of whereClause to be able to retrieve valued vars This solution introduce some complexity that might affect the performance of the query builder and retrieving the var. Therefore we should not consider this solution as a final solution but rather an example of how to isolate concerns with interfaces with Go. There must be some work to be done if we want to optimize both the builder and the getter of the query.
top level abstraction for the exported Select struct
Add utilities to read the results of select statement SurrealQL query as well as the utilities to execute a select query. There are no integration tests. I only added a very basic unit test. Mostly to test the behavior of surrealdb.Unmarshal.
Add NewConditionOr and new NewConditionAnd, both accept unlimited conditions with at least one condition.
surrealDriver support Update(what, data) Add DocID interface for documents with Id. Note that we might want to refactor this but remember we want to stay backward compatible.
release see scope: NewDefaultDoc |
pushed to canonical, please let's focus on this branch now, specially I want to feature #16 see also https://github.com/topics/code-generator?l=go |
closed in favor of #17 |
For further details please read the details from the commit messages.
I will squash and merge to keep a detailed documentation of the changes.
This proof of concept (poc) only includes
The query builder is not optimized it is using too many parentheses without trying to simplify composition of AND operators and composition of OR operators but we could say that it is satisfying for now.
Another caveat is the data-structure used for recursive OR and recursive AND that could be optimized to use of slices.
In the context of this poc, the query driver supports
SelectOn
and thenselectDriver.Update
on the first selected document if any otherwise it returns ErrNoDoctag v0.2.2
EDIT
tag version v0.2.0 -> v0.2.1 (d9a1927)
tag version v0.2.1 -> v0.2.2 (20a99ce)