Skip to content

Commit

Permalink
(PDB-5743) Fix join-deps for latest_report_status
Browse files Browse the repository at this point in the history
Without another reference to a field that depends on the certnames
table, a query for latest_report_status will fail with the error.

    ERROR: missing FROM-clause entry for table "certnames"

latest_report_status needs the certnames table in order to know the
latest_report_id that it needs to join against the reports table.

Fixes #3966
  • Loading branch information
austb committed Apr 15, 2024
1 parent 54961d2 commit d0b2156
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/puppetlabs/puppetdb/query_eng/engine.clj
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@
"latest_report_status" {:type :string
:queryable? true
:field :report_statuses.status
:join-deps #{:report_statuses :reports}}
:join-deps #{:certnames :report_statuses :reports}}
"latest_report_corrective_change" {:type :boolean
:queryable? true
:field :reports.corrective_change
Expand Down
4 changes: 3 additions & 1 deletion test/puppetlabs/puppetdb/http/nodes_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@
(testing "querying on latest report status works"
(is-query-result' ["=" "latest_report_status" "success"] [])
(is-query-result' ["=" "latest_report_status" "failure"] [])
(is-query-result' ["=" "latest_report_status" "unchanged"] [web1 db puppet]))
(is-query-result' ["=" "latest_report_status" "unchanged"] [web1 db puppet])
(is (= #{{:latest_report_status nil} {:latest_report_status "unchanged"}}
(query-result method endpoint ["extract" ["latest_report_status"]]))))

(testing "querying on latest report noop works"
(is-query-result' ["=" "latest_report_noop" true] [])
Expand Down

0 comments on commit d0b2156

Please sign in to comment.