Skip to content

Commit 96e3731

Browse files
Nuo Yandanielsdeleo
authored andcommitted
fixing CHEF-1264
1 parent 3904ab7 commit 96e3731

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎chef-server-api/app/controllers/search.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def show
4040
raise NotFound, "I don't know how to search for #{params[:id]} data objects."
4141
end
4242

43-
query = Chef::Solr::Query.new(Chef::Config[:solr_url], Chef::Config[:couchdb_database])
43+
query = Chef::Solr::Query.new(Chef::Config[:solr_url])
4444
params[:q] ||= "*:*"
4545
params[:sort] ||= nil
4646
params[:start] ||= 0

‎chef-solr/lib/chef/solr/query.rb‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#
22
# Author:: Adam Jacob (<adam@opscode.com>)
3-
# Copyright:: Copyright (c) 2009 Opscode, Inc.
3+
# Author:: Nuo Yan (<nuo@opscode.com>)
4+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
45
# License:: Apache License, Version 2.0
56
#
67
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,11 +31,22 @@ class Solr
3031
class Query < Chef::Solr
3132

3233
# Create a new Query object - takes the solr_url and optional
33-
# couchdb_database to inflate objects into.
34-
def initialize(solr_url=Chef::Config[:solr_url], database=Chef::Config[:couchdb_database])
34+
# Chef::CouchDB object to inflate objects into.
35+
def initialize(solr_url=Chef::Config[:solr_url], couchdb = nil)
3536
super(solr_url)
36-
@database = database
37-
@couchdb = Chef::CouchDB.new(nil, database)
37+
if couchdb.nil?
38+
@database = Chef::Config[:couchdb_database]
39+
@couchdb = Chef::CouchDB.new(nil, Chef::Config[:couchdb_database])
40+
else
41+
unless couchdb.kind_of?(Chef::CouchDB)
42+
Chef::Log.warn("Passing the database name to Chef::Solr::Query initialization is deprecated. Please pass in the Chef::CouchDB object instead.")
43+
@database = couchdb
44+
@couchdb = Chef::CouchDB.new(nil, couchdb)
45+
else
46+
@database = couchdb.couchdb_database
47+
@couchdb = couchdb
48+
end
49+
end
3850
end
3951

4052
# A raw query against CouchDB - takes the type of object to find, and raw

0 commit comments

Comments
 (0)