File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
src/puppetlabs/puppetdb/query_eng
test/puppetlabs/puppetdb/http Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 21752175 into its function name. Throws an IllegalArgumentException if there is an
21762176 invalid field or function"
21772177 [query-rec column-or-fn-name]
2178- (or (get-in query-rec [:projections column-or-fn-name :field ])
2179- (if (some #{column-or-fn-name} (keys pdb-fns->pg-fns))
2180- (keyword column-or-fn-name)
2181- (throw (IllegalArgumentException.
2182- (tru " {0} is niether a valid column name nor function name"
2183- (pr-str column-or-fn-name)))))))
2178+ ; ; Just split on dot for now (as a hack) - we'll use the strict
2179+ ; ; parser once it's available (after 6.18.0 and 7.5.0)."
2180+ (let [[root] (str/split column-or-fn-name #"\. " 2 )]
2181+ (or (get-in query-rec [:projections root :field ])
2182+ (if (some #{column-or-fn-name} (keys pdb-fns->pg-fns))
2183+ (keyword column-or-fn-name)
2184+ (throw (IllegalArgumentException.
2185+ (tru " {0} is niether a valid column name nor function name"
2186+ (pr-str column-or-fn-name))))))))
21842187
21852188(defn group-by-entries->fields
21862189 " Convert a list of group by columns and functions to their true SQL field names."
Original file line number Diff line number Diff line change 170170
171171 ; ; TODO figure out what behavior we want for queries with null w/o a dotted path
172172 [" null?" " facts" true ]
173- #{})))
173+ #{}
174+
175+ [" extract" [[" function" , " count" ] " facts.domain" ]
176+ [" group_by" " facts.domain" ]]
177+ #{{:facts.domain " testing.com" :count 1 }
178+ {:facts.domain nil :count 1 }})))
174179
175180(deftest-http-app inventory-queries
176181 [[version endpoint] inventory-endpoints
213218 [[" function" " count" " certname" ]]
214219 [" in" " facts.os.family" [" array" [" RedHat" ]]]]
215220 {:keys [body status]} (query-response method endpoint query)]
216- (is (= status 500 ))
217- (is (= body " Value does not match schema: (not (map? nil))" ))))
221+ (is (= 500 status ))
222+ (is (= " Value does not match schema: (not (map? nil))" body ))))
218223
219224 (testing " inventory queries"
220225 (testing " well-formed queries"
224229 (get-request endpoint (json/generate-string query))
225230 (get-request endpoint))
226231 {:keys [status body headers]} (*app* request)]
227- (is (= status http/status-ok))
232+ (is (= http/status-ok status ))
228233 (is (http/json-utf8-ctype? (headers " Content-Type" )))
229234 (is (= (set result)
230235 (set (json/parse-string (slurp body) true )))))))))))
You can’t perform that action at this time.
0 commit comments