-
Notifications
You must be signed in to change notification settings - Fork 75
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
Removed parentheses from filtering #256
Conversation
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
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.
Looks to be dead simple.
I was just looking at a more recent version of the docs: https://code.vmware.com/docs/8072/vcloud-director-api-programming-guide/GUID-CDF04296-5EB5-47E1-9BEC-228837C584CE.html
Main concern from me, is the "grouping" (parenthesis) not used so that it matches both conditions (logical and) while without parenthesis would be logical or?
In such case a query with multiple fields may have different results or am I wrong?
This one would look for objects matching both conditions - name
to be "name" and orgName
to be "adminOrg.AdminOrg.Name":
"filter": fmt.Sprintf("(name==%s;orgName==%s)", url.QueryEscape(name), url.QueryEscape(adminOrg.AdminOrg.Name)),
While this one would look for objects whose name
matches "name" or orgName
matches "adminOrg.AdminOrg.Name"
"filter": fmt.Sprintf("name==%s;orgName==%s", url.QueryEscape(name), url.QueryEscape(adminOrg.AdminOrg.Name)),
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 few small changes required. LGTM otherwise
CHANGELOG.md
Outdated
@@ -4,6 +4,9 @@ | |||
to allow understand if value was returned or not. | |||
* Added method VApp.AddNewVMWithStorageProfile that adds a VM with custom storage profile. | |||
|
|||
BUGS FIXED: | |||
* Removed parentheses from filtering which in some env wasn't treated correctly [#256] (https://github.com/vmware/go-vcloud-director/pull/256) |
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.
* Removed parentheses from filtering which in some env wasn't treated correctly [#256] (https://github.com/vmware/go-vcloud-director/pull/256) | |
* Removed parentheses from filtering since they weren't treated correctly in some environment [#256] (https://github.com/vmware/go-vcloud-director/pull/256) |
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.
updated
govcd/api.go
Outdated
@@ -122,7 +122,7 @@ func ContainsNotFound(err error) bool { | |||
return err != nil && strings.Contains(err.Error(), ErrorEntityNotFound.Error()) | |||
} | |||
|
|||
// Function allow to pass complex values params which shouldn't be encoded like for queries. e.g. /query?filter=(name=foo) | |||
// Function allow to pass complex values params which shouldn't be encoded like for queries. e.g. /query?filter=name=foo |
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.
// Function allow to pass complex values params which shouldn't be encoded like for queries. e.g. /query?filter=name=foo | |
// NewRequestWitNotEncodedParams allows passing complex values params that shouldn't be encoded like for queries. e.g. /query?filter=name=foo |
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.
update
We can't 100% rely on latest docs as we working still with older versions.
|
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Parentheses are needed only if we have groups, or sub-expression. If we have only one set of parentheses, they should be superfluous, as we are grouping the only sub-expression in the condition. |
Alright. I am sold :) The example in website confused me initially having
|
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
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.
LGTM, but in the commit message, please explain why these parentheses were doing harm - I don't see a single note about that in this PR.
Fix for https://github.com/terraform-providers/terraform-provider-vcd/issues/287
Parentheses isn't needed(accordig documentation used when need to create sophisticated filtering) and if we will need to use them later - we have to figure out how to escape them, as in different env behaves differently.
Building query docs: https://pubs.vmware.com/vcloud-api-1-5/wwhelp/wwhimpl/js/html/wwhelp.htm#href=api_prog/GUID-CDF04296-5EB5-47E1-9BEC-228837C584CE.html#1_22_9_1