File tree 2 files changed +18
-2
lines changed
src/puppetlabs/puppetdb/query_eng
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1806
1806
1807
1807
[[(op :guard #{" =" " >" " <" " <=" " >=" " ~" }) (column :guard validate-dotted-field) value]]
1808
1808
; ; (= :inventory (get-in (meta node) [:query-context :entity]))
1809
- (when (string/includes? column " match(" )
1809
+ (if (string/includes? column " match(" )
1810
1810
(let [[head & path] (->> column
1811
1811
utils/parse-matchfields
1812
1812
su/dotted-query->path
1819
1819
(map :path_array )
1820
1820
(map (fn [path] (if (= (first path) " trusted" ) path (cons " facts" path))))
1821
1821
(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]))
1823
1826
1824
1827
[[" extract" (columns :guard numeric-fact-functions?) (expr :guard no-type-restriction?)]]
1825
1828
(when (= :facts (get-in meta node [:query-context :entity ]))
Original file line number Diff line number Diff line change 178
178
:results-query
179
179
first)))))
180
180
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
+
181
194
(deftest test-valid-query-operators
182
195
(is (thrown-with-msg? IllegalArgumentException
183
196
#"'and' takes at least one argument, but none were supplied"
You can’t perform that action at this time.
0 commit comments