Project

General

Profile

Actions

Bug #2193

closed

Wrong parenthesis used at hosts.rb

Added by Dennis Hoppe over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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

Actions

Also available in: Atom PDF