diff --git a/.gitignore b/.gitignore index c1e0daf..67d5886 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ tmtags ## VIM *.swp +## IntelliJ/Rubymine +.idea + ## PROJECT::GENERAL coverage rdoc diff --git a/lib/postgresql_cursor.rb b/lib/postgresql_cursor.rb index 8ee98e9..6dbad1b 100644 --- a/lib/postgresql_cursor.rb +++ b/lib/postgresql_cursor.rb @@ -117,7 +117,6 @@ def set_cursor_tuple_fraction(frac=1.0) # Defines extension to ActiveRecord to use this library class ActiveRecord::Base - # Public: Returns each row as a hash to the given block # # sql - Full SQL statement, variables interpolated @@ -129,6 +128,7 @@ class ActiveRecord::Base # # Returns the number of rows yielded to the block def self.each_row_by_sql(sql, options={}, &block) + options = {:connection => self.connection}.merge(options) PostgreSQLCursor.new(sql, options).each(&block) end @@ -139,6 +139,7 @@ def self.each_row_by_sql(sql, options={}, &block) # # Returns the number of rows yielded to the block def self.each_instance_by_sql(sql, options={}, &block) + options = {:connection => self.connection}.merge(options) PostgreSQLCursor.new(sql, options).each do |row| model = instantiate(row) yield model @@ -160,6 +161,7 @@ class ActiveRecord::Relation # # Returns the number of rows yielded to the block def each_row(options={}, &block) + options = {:connection => self.connection}.merge(options) PostgreSQLCursor.new(to_sql, options).each(&block) end @@ -169,6 +171,7 @@ def each_row(options={}, &block) # # Returns the number of rows yielded to the block def each_instance(options={}, &block) + options = {:connection => self.connection}.merge(options) PostgreSQLCursor.new(to_sql, options).each do |row| model = instantiate(row) block.call model