diff --git a/pkg/flags/c8yQuery.go b/pkg/flags/c8yQuery.go index 86df8a63f..8562280b8 100644 --- a/pkg/flags/c8yQuery.go +++ b/pkg/flags/c8yQuery.go @@ -76,7 +76,7 @@ func BuildCumulocityQuery(cmd *cobra.Command, fixedParts []string, orderBy strin } if len(b) > 0 { - queryParts = append(queryParts, "("+string(b)+")") + queryParts = append(queryParts, string(b)) } if v, err := cmd.Flags().GetString("queryTemplate"); err == nil && v != "" { diff --git a/tests/manual/devices/list/devices_list.yaml b/tests/manual/devices/list/devices_list.yaml new file mode 100644 index 000000000..bdfe2d195 --- /dev/null +++ b/tests/manual/devices/list/devices_list.yaml @@ -0,0 +1,18 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/reubenmiller/commander/feat/handle-nested-files/schema.json +config: + env: + C8Y_SETTINGS_DEFAULTS_CACHE: true + C8Y_SETTINGS_CACHE_METHODS: GET POST PUT + C8Y_SETTINGS_DEFAULTS_CACHETTL: 100h + C8Y_SETTINGS_DEFAULTS_OUTPUT: csv + + +tests: + It can build an inventory query via piped input: + command: | + echo "type1" | c8y devices list --queryTemplate "type eq '%s'" --dry | + c8y util show --select pathEncoded + exit-code: 0 + stdout: + exactly: | + /inventory/managedObjects?q=$filter=type+eq+'type1'+$orderby=name