Skip to content

Commit 976f6bb

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 82fb00f commit 976f6bb

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
@@ -2185,7 +2185,7 @@
21852185
:field]))
21862186
;; Turn facts.foo into a double quoted keyword so that the SQL identifier `:"facts.foo"`
21872187
;; matches the extraction of (fs.volatile||fs.stable) AS "facts.foo" from the selection
2188-
(keyword (jdbc/double-quote column-or-fn-name))
2188+
(htypes/raw (jdbc/double-quote column-or-fn-name))
21892189
(or (get-in query-rec [:projections column-or-fn-name :field])
21902190
(if (some #{column-or-fn-name} (keys pdb-fns->pg-fns))
21912191
(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)