lib/hiera/backend/mysql2_backend.rb in hiera-mysql-backend-0.0.8 vs lib/hiera/backend/mysql2_backend.rb in hiera-mysql-backend-0.0.9

- old
+ new

@@ -70,22 +70,28 @@ def query(connection_hash, query) Hiera.debug("Executing SQL Query: #{query}") - data=nil + data=[] + mysql_host=connection_hash[:host] + mysql_user=connection_hash[:username] + mysql_pass=connection_hash[:password] + mysql_database=connection_hash[:database] + mysql_port=connection_hash[:port] + if defined?(JRUBY_VERSION) Jdbc::MySQL.load_driver url = "jdbc:mysql://#{mysql_host}:#{mysql_port}/#{mysql_database}" props = java.util.Properties.new props.set_property :user, mysql_user props.set_property :password, mysql_pass conn = com.mysql.jdbc.Driver.new.connect(url,props) stmt = conn.create_statement - res = stmt.execute_query(sql) + res = stmt.execute_query(query) md = res.getMetaData numcols = md.getColumnCount Hiera.debug("Mysql Query returned #{numcols} rows") @@ -116,9 +122,8 @@ end return data end - end end end