File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
src/puppetlabs/puppetdb/query_eng Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 18061806
18071807 [[(op :guard #{" =" " >" " <" " <=" " >=" " ~" }) (column :guard validate-dotted-field) value]]
18081808 ; ; (= :inventory (get-in (meta node) [:query-context :entity]))
1809- (when (string/includes? column " match(" )
1809+ (if (string/includes? column " match(" )
18101810 (let [[head & path] (->> column
18111811 utils/parse-matchfields
18121812 su/dotted-query->path
18191819 (map :path_array )
18201820 (map (fn [path] (if (= (first path) " trusted" ) path (cons " facts" path))))
18211821 (map #(string/join " ." %)))]
1822- (into [" or" ] (map #(vector op % value) fact_paths))))
1822+ (into [" or" ] (map #(vector op % value) fact_paths)))
1823+ (if (re-matches #"^trusted.*" column)
1824+ [op (str " facts." column) value]
1825+ [op column value]))
18231826
18241827 [[" extract" (columns :guard numeric-fact-functions?) (expr :guard no-type-restriction?)]]
18251828 (when (= :facts (get-in meta node [:query-context :entity ]))
Original file line number Diff line number Diff line change 178178 :results-query
179179 first)))))
180180
181+ (deftest index-hit-for-trusted-facts-on-inventory
182+ (testing " facts.trusted.extensions and trusted.extensions should generate the same SQL"
183+ (is (re-find #"WHERE \( fs.stable||fs.volatile\) @> ?"
184+ (->> [" extract" [] [" =" " facts.trusted.extensions.foo" " bar" ]]
185+ (compile-user-query->sql inventory-query)
186+ :results-query
187+ first)))
188+ (is (re-find #"WHERE \( fs.stable||fs.volatile\) @> ?"
189+ (->> [" extract" [] [" =" " trusted.extensions.foo" " bar" ]]
190+ (compile-user-query->sql inventory-query)
191+ :results-query
192+ first)))))
193+
181194(deftest test-valid-query-operators
182195 (is (thrown-with-msg? IllegalArgumentException
183196 #"'and' takes at least one argument, but none were supplied"
You can’t perform that action at this time.
0 commit comments