lib/hiera/backend/mysql_json_backend.rb in hiera-mysql-json-backend-jruby-1.1.0 vs lib/hiera/backend/mysql_json_backend.rb in hiera-mysql-json-backend-jruby-1.1.1
- old
+ new
@@ -23,11 +23,11 @@
def should_lookup?(constraints, scope)
return true unless constraints.is_a?(Hash)
should_lookup = false
constraints.each do |item, matchers|
- next unless scope.exist?(item.to_s)
+ next unless scope[item.to_s]
if scope[item.to_s] =~ compile_regexes(matchers)
should_lookup = true
break
end
end
@@ -83,10 +83,10 @@
Hiera.debug("Found #{key} in #{source}")
new_answer = Backend.parse_answer(data[key], scope)
sql_results = query(connection_hash, new_answer)
-
+ # TODO: make sure we fail if we have more than 1 result, skip if less than 1.
next if sql_results.length != 1
begin
new_answer = JSON.parse(sql_results[0]['value'])
rescue
raise Exception, "JSON parse error for key '#{key}'." unless Config[:mysql_json][:ignore_json_parse_errors]