-
Notifications
You must be signed in to change notification settings - Fork 882
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
Add documentation about QueryBuilder #1031
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very comprehensive guide, truly impressive work.
My remarks are all about style, but please keep in mind that I'm not a native English speaker either, so you might want to get this PR reviewed by someone whose native language is English.
@@ -1,5 +1,268 @@ | |||
## Built statements | |||
|
|||
*Coming soon... In the meantime, see the javadoc for [QueryBuilder].* | |||
Built statements are generated via [QueryBuilder]'s Fluent API. Use of Fluent API allows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "Use of Fluent API allows for easier build of complex queries, as opposed to the use of hardcoded query strings."
manual/statements/built/README.md
Outdated
Note: The provider builders perform very little validation of the built query. There is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "The provided builders".
manual/statements/built/README.md
Outdated
invalid queries. | ||
|
||
Queries built with `QueryBuilder` are execute the same way as other queries - via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "are executed"
manual/statements/built/README.md
Outdated
|
||
Queries built with `QueryBuilder` are execute the same way as other queries - via | ||
`execute` or `executeAsync`. When query is built with putting all data into it, then it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: " When a query is built with inlined values, then it doesn't differ much from a statement specified as a string."
manual/statements/built/README.md
Outdated
`execute` or `executeAsync`. When query is built with putting all data into it, then it | ||
doesn't differ much from statement specified as string. But it's also possible to build | ||
the query with bind markers inside it, and then convert it into [prepared statement](../prepared/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "into a prepared statement".
manual/statements/built/README.md
Outdated
|
||
Specification of conditions is similar to the other operations described above, including | ||
conditional delete with `ifExists` & `onlyIf`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "conditional deletes".
manual/statements/built/README.md
Outdated
|
||
If you're repeating the same operation very often, the more effective way will be to | ||
create the [prepared statement](../prepared/) from the `BuiltStatement`. To do it, instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "...create a prepared statement"
manual/statements/built/README.md
Outdated
If you're repeating the same operation very often, the more effective way will be to | ||
create the [prepared statement](../prepared/) from the `BuiltStatement`. To do it, instead | ||
of the real values, use the bind marker that is created either by calling of `bindMarker` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "...use bind markers created either by calling bindMarker
(which generates a positional placeholder), or by calling bindMarker("name")
(which creates a named placeholder)."
manual/statements/built/README.md
Outdated
### Setting additional options | ||
|
||
As in the case of the usual statements, you can also set additional options for given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "As it is the case for regular statements, you can also set options on built statements such as the consistency level..."
manual/statements/built/README.md
Outdated
(with `enableTracing`/`disableTracing`), retry policy (with `setRetryPolicy`), etc. | ||
|
||
Note: the call to these functions changes the object type from `BuiltStatement` to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "from
BuiltStatementto
Statementor
RegularStatement`"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome contribution, thanks!
See a few typos and style suggestions inline.
Also it would be nice to show the generated CQL query for each example, as we did in the driver 4 manual.
manual/statements/built/README.md
Outdated
[QueryBuilder]: http://docs.datastax.com/en/drivers/java/3.5/com/datastax/driver/core/querybuilder/QueryBuilder.html | ||
[TableMetadata]: http://docs.datastax.com/en/drivers/java/3.5/com/datastax/driver/core/TableMetadata.html | ||
[SchemaBuilder]: https://docs.datastax.com/en/drivers/java/3.5/com/datastax/driver/core/schemabuilder/SchemaBuilder.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: consistently use https
in all URLs.
manual/statements/built/README.md
Outdated
|
||
Queries built with `QueryBuilder` are executed the same way as other queries--via | ||
`execute` or `executeAsync`. When query is built with inlined values, then it doesn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"When a query is built"?
manual/statements/built/README.md
Outdated
|
||
Generation of `BuiltStatement` is easy--start by calling of one of the | ||
[QueryBuilder]'s methods of that represent the CQL's "verb": `select`, `update`, `delete`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous "of"?
"methods that represent"
manual/statements/built/README.md
Outdated
Note: The `QueryBuilder` doesn't provide support for the full set of CQL. For | ||
DDL operations (`CREATE TABLE`, etc.) you can use the [SchemaBuilder]. To perform other | ||
operations you still need to use [simple statements](../simple/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any example of queries that are neither covered by QueryBuilder
nor SchemaBuilder
? We try to stay pretty up-to-date...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example, there is no support for ALTER TYPE
,CREATE MATERIALIZED VIEW
, roles management, etc.
manual/statements/built/README.md
Outdated
Besides selection of the specific columns, there is also a possibility of calling of | ||
arbitrary CQL function by using the `fcall` (this is just example, don't do this on real | ||
data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say "calling arbitrary CQL functions by using the fcall
method
manual/statements/built/README.md
Outdated
### Inserting data | ||
|
||
Insertion of data is straightforward--you specify the target table in call to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a call"?
manual/statements/built/README.md
Outdated
``` | ||
|
||
It also possible to specify additional metadata for inserted data, such as TTL (time to live) or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"It is also possible"
manual/statements/built/README.md
Outdated
|
||
It also possible to specify additional metadata for inserted data, such as TTL (time to live) or | ||
timestamp. This is achieved by using the `using` function and providing the `Using` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could say "achieved with the using
method" to avoid the repetition.
manual/statements/built/README.md
Outdated
``` | ||
|
||
Besides the most often used `set` operation, there is a plenty of operations for work with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"plenty of operations" / "lots of operations"
manual/statements/built/README.md
Outdated
Similarly to insert statements, it's also possible to perform conditional updates by | ||
calling either `ifExists` (to perform the update only if the entry exists), or by calling | ||
`onlyIf` with a `Clause` object—in this case the row will be updated only if the clause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use --
like you did in other places
Thank you for comments @olim7t ! I've pushed fixes for them... |
Merged, thanks @alexott! |
No description provided.