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 authored and rbrw committed Apr 15, 2024
1 parent 54961d2 commit 7e6e3e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions documentation/release_notes_8.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ canonical: "/puppetdb/latest/release_notes.html"

# PuppetDB: Release notes

## PuppetDB 8.5.1

Released TBD.

### Bug fixes

* Fix an error when querying for `nodes` and `latest_report_status`
[GitHub #3966](https://github.com/puppetlabs/puppetdb/issues/3966)

### Contributors

Austin Blatt and ...

## PuppetDB 8.5.0

Released April 11 2024
Expand Down
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 7e6e3e0

Please sign in to comment.