Project

General

Profile

Actions

Bug #2193

closed

Wrong parenthesis used at hosts.rb

Added by Dennis Hoppe about 11 years ago. Updated about 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 #1

Updated by Joseph Magen about 11 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

Actions #2

Updated by Dennis Hoppe about 11 years ago

Hello Joseph,

i tested your code and it fixed the SQL Error.

Regards, Dennis

Actions #3

Updated by Ohad Levy about 11 years ago

  • Target version set to 1.2.0
Actions #4

Updated by Dennis Hoppe about 11 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF