Actions
Bug #2193
closedWrong parenthesis used at hosts.rb
Description
Hello,
i am using Foreman 1.1 with PostgreSQL 9.1 as database backend and the link "All Puppet Classes" is throwing the following SQL Error:
PG::Error: FEHLER: Spalte »Class« existiert nicht LINE 1: ...s" WHERE ("resources".host_id = 7) AND (restype = "Class" AN... ^ : SELECT title FROM "resources" WHERE ("resources".host_id = 7) AND (restype = "Class" AND title != "main" AND title != "Settings") ORDER BY title ActiveRecord::StatementInvalid PG::Error: FEHLER: Spalte »Class« existiert nicht LINE 1: ...s" WHERE ("resources".host_id = 7) AND (restype = "Class" AN... ^ : SELECT title FROM "resources" WHERE ("resources".host_id = 7) AND (restype = "Class" AND title != "main" AND title != "Settings") ORDER BY title app/models/host.rb:606:in `classes_from_storeconfigs' app/views/hosts/storeconfig_klasses.html.erb:6:in `_app_views_hosts_storeconfig_klasses_html_erb___1446665967_70110018225800_0' lib/foreman/thread_session.rb:31:in `clear_thread'
You should change the parenthesis at "/usr/share/foreman/app/models/hosts.rb" to make this work with PostgreSQL.
root@puppet:/usr/share/foreman/app/models# diff -Naur host.rb_2013-02-08 host.rb --- host.rb_2013-02-08 2013-02-08 17:06:27.822667417 +0100 +++ host.rb 2013-02-08 17:09:03.725967925 +0100 @@ -603,7 +603,7 @@ end def classes_from_storeconfigs - klasses = resources.all(:conditions => 'restype = "Class" AND title != "main" AND title != "Settings"', :select => :title, :order => :title) + klasses = resources.all(:conditions => "restype = 'Class' AND title != 'main' AND title != 'Settings'", :select => :title, :order => :title) klasses.map!(&:title).delete(:main) klasses end
Regards, Dennis
Updated by Joseph Magen almost 12 years ago
- Status changed from New to Ready For Testing
- Assignee set to Joseph Magen
Dennis,
Can you check if this fixes the SQL Error?
klasses = resources.select(:title).where(:restype => "Class").where("title <> ? AND title <> ?", "main", "Settings").order(:title)
I also issued a pull request with this fix - https://github.com/theforeman/foreman/pull/404
Thanks,
Joseph
Updated by Dennis Hoppe almost 12 years ago
Hello Joseph,
i tested your code and it fixed the SQL Error.
Regards, Dennis
Updated by Dennis Hoppe almost 12 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 836153886c1bd7ac36bbb67fef111fb0b907167b.
Actions