Bug #1607

REST API calls /hosts/:id/puppetclasses fails with postgres

Added by Florent Castelli about 1 year ago. Updated 11 months ago.

Status:Closed Start:05/09/2012
Priority:Normal Due date:
Assigned to:- % Done:

100%

Category:-
Target version:-
Backlog:No Difficulity:
Votes: 0

Description

Calling /hosts/:id:puppetclasses fails with postgres.
The SQL request has an ORDER BY clause on a field not selected.

Suggested fix is to remove the default_scope in app/models/puppetclass.rb

Associated revisions

Revision cbf4be7cfaee8c2b82c833f0f24e914ab50ef238
Added by Florent Castelli 11 months ago

Fixes puppetclasses search with pg database

The request is sorting the results on a field that isn't in the DISTINCT
SELECT'ed columns and pg doesn't like it.
Fixes #1607

History

Updated by Florent Castelli about 1 year ago

Puppetclass Load (0.7ms) SELECT DISTINCT puppetclasses.id FROM "puppetclasses" INNER JOIN "host_classes" ON "puppetclasses"."id" = "host_classes"."puppetclass_id" INNER JOIN "hosts" ON "hosts"."id" = "host_classes"."host_id" WHERE (hosts.name = 'somehost') ORDER BY LOWER
PG::Error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...osts.name = 'somehost') ORDER BY LOWER(pupp...
^
: SELECT DISTINCT puppetclasses.id FROM "puppetclasses" INNER JOIN "host_classes" ON "puppetclasses"."id" = "host_classes"."puppetclass_id" INNER JOIN "hosts" ON "hosts"."id" = "host_classes"."host_id" WHERE (hosts.name = 'somehost') ORDER BY LOWER

Updated by Ohad Levy 12 months ago

  • Status changed from New to Need more information

is this still releavant? is this one of the merged pull requests and I just missed this ticket?

Updated by Florent Castelli 11 months ago

  • Status changed from Need more information to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF