postgresql_cursor
postgresql_cursor copied to clipboard
ActiveRecord PostgreSQL Adapter extension for using a cursor to return a large result set
It avoids issues when a transaction fails, thus the statement to close the cursor will fail. In addition this obscures the underlying error in the user code due to raising...
`each_instance` incorrectly sets the column types, for example ```ruby class User < ActiveRecord::Base enum state: { active: 1, } end pp User.first # # pp User.each_instance.first # # ``` **Expected.**...
Looking at https://github.com/afair/postgresql_cursor/blob/master/lib/postgresql_cursor/cursor.rb#L298, the comment explains that the gem prefers to override PostgreSQL's default `cursor_tuple_fraction = 0.1` to `1.0`. However because the arg `frac=1.0` and there's an default on the...
I use `#each_instance_batch` method to iterate over batches, and when it tries to find column types for postgresql `enum` columns it warns https://github.com/afair/postgresql_cursor/blob/4bec7faf1612ad9377cd618a91558a81dfdd84b7/lib/postgresql_cursor/cursor.rb#L238 ``` /gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:698: warning: deprecated Object#=~ is called...
We have discovered that this gem doesn't handle properly the ActiveRecord `none` method. ``` subscriptions = Subscription.none subscriptions.each_row { |row| p row } ``` The above code raises: ``` ActiveRecord::StatementInvalid:...
Currently, I have my main code working where I run `each_row` on my ActiveRecord Relation. But in the test, I have an array, and the original code used to be...
block variable for `each_row` is a `Hash`. Use `each_instance` instead.
Our app opens a cursor which can run for hours at a time. On the longer runs (7+ hours) the cursor occasionally errors out with: ``` ActiveRecord::StatementInvalid PG::ConnectionBad: PQsocket() can't...
The early return removed the ability to override Postgres' default fraction of `0.1` with `1.0`. A workaround was to use `0.99999` but that's a little bit ugly, so let's just...
This PR drops support for EOL Rubies (i.e. Ruby < 2.7) and EOL Rails (i.e. Rails < 6.0). It also adds every minor Ruby and Rails version to the test...