Skip to content

Commit c5ab459

Browse files
committed
(PDB-5278) Fix group by dotted fact path with forward slash
When grouping by a keyword, honeysql will convert the keyword to SQL by calling `name` on it. But that will not return the entire fact name when there's a forward slash in it because Clojure interprets everything before the forward slash as the "namespace" and everything after as the "name". ``` => (name :facts.foo) "facts.foo" => (name :facts.f/oo) "oo" => (namespace :facts.f/oo) "facts.f" ``` This commit changes the query engine to use sql raw instead of the keyword to avoid splitting on forward slashes.
1 parent 1043595 commit c5ab459

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/puppetlabs/puppetdb/query_eng/engine.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@
22652265
:field]))
22662266
;; Turn facts.foo into a double quoted keyword so that the SQL identifier `:"facts.foo"`
22672267
;; matches the extraction of (fs.volatile||fs.stable) AS "facts.foo" from the selection
2268-
(keyword (jdbc/double-quote column-or-fn-name))
2268+
(htypes/raw (jdbc/double-quote column-or-fn-name))
22692269
(or (get-in query-rec [:projections column-or-fn-name :field])
22702270
(if (some #{column-or-fn-name} (keys pdb-fns->pg-fns))
22712271
(keyword column-or-fn-name)

test/puppetlabs/puppetdb/http/inventory_test.clj

+8
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@
172172
["null?" "facts" true]
173173
#{}
174174

175+
["extract" ["facts.foo"]
176+
["group_by" "facts.foo"]]
177+
#{{:facts.foo nil}}
178+
179+
["extract" ["facts.f/oo"]
180+
["group_by" "facts.f/oo"]]
181+
#{{:facts.f/oo nil}}
182+
175183
["extract" [["function", "count"] "facts.domain"]
176184
["group_by" "facts.domain"]]
177185
#{{:facts.domain "testing.com" :count 2}

0 commit comments

Comments
 (0)