lib/mini_sql/postgres/connection.rb in mini_sql-1.0 vs lib/mini_sql/postgres/connection.rb in mini_sql-1.0.1
- old
+ new
@@ -95,11 +95,13 @@
result.clear if result
end
def query_each(sql, *params)
raise StandardError, "Please supply a block when calling query_each" if !block_given?
- sql = param_encoder.encode(sql, *params)
+ if params && params.length > 0
+ sql = param_encoder.encode(sql, *params)
+ end
raw_connection.send_query(sql)
raw_connection.set_single_row_mode
loop do
@@ -126,11 +128,13 @@
end
end
def query_each_hash(sql, *params)
raise StandardError, "Please supply a block when calling query_each_hash" if !block_given?
- sql = param_encoder.encode(sql, *params)
+ if params && params.length > 0
+ sql = param_encoder.encode(sql, *params)
+ end
raw_connection.send_query(sql)
raw_connection.set_single_row_mode
loop do
@@ -189,10 +193,12 @@
end
private
def run(sql, params)
- sql = param_encoder.encode(sql, *params)
+ if params && params.length > 0
+ sql = param_encoder.encode(sql, *params)
+ end
raw_connection.async_exec(sql)
end
end
end