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
Should conditionless queries be removed? #4050
Comments
Can you give an example of the "pro" listed and what it avoids? |
I'm in favour of this but we should implement it so that folks relying on this behaviour can no longer create these conditionless queries. This means creating constructors that take the required parameters and moving to descriptors that take these values as first arguments. This is a bit of a break with established patterns everywhere else |
Explicit over implicit. Only the developer who constructs queries knows is this a desired/intended behaviour when control flow resulted in passing empty/null values to query or this is a bug. Responsibility of the library is to safe user from hidden mistakes, do not allow to shoot yourself in the foot. Perhaps it makes sense to move this settings to the global level to preserve the habits of folks and to allow developers to choose. |
For the initial 8.0 alpha 1 release we have removed condition-less queries. A work item will review adding back support via a configuration option vs. ensuring we generate appropriate constructors. |
From the conversation in #4020, this issue serves as a discussion on whether to consider removing conditionless queries from the client in 8.0.
As background, conditionless queries have been a part of the high level client, NEST, since 1.x, and are intended to make writing complex queries easier, avoiding the need for the user to check inputs and conditionally add components of a query.
Consider the following
terms
queryConditionless behaviour would result in the following query being sent
because the
terms
query input is an array with a single empty string. Anull
terms input, an input with no items, or an input where all items arenull
or an empty string would all result in the same behaviour, that of theterms
query being excluded from the serialized query JSON.Conditionless behaviour can be overridden by marking a query as verbatim
which would result in
Pros for conditionless queries
Cons against conditionless queries
Thoughts @Mpdreamz, @codebrain, @philkra ?
The text was updated successfully, but these errors were encountered: