-
Notifications
You must be signed in to change notification settings - Fork 47
Description
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 options lookup @cursor_tuple_fraction ||= @options.fetch(:fraction) { 1.0 }
, I believe the early return return @cursor_tuple_fraction if frac == @cursor_tuple_fraction
will always fire unless you set a custom value not equal to 1.0
.
This means both that the 1.0
default never gets applied, and also that it's impossible to apply a configuration value of 1.0
.
I think the early return probably is an unnecessary optimization in terms of speed, and having any early return will possibly cause bugs since the default config on a given Postgres install might not be 0.1
anyway, so it's not possible to fully fix by changing to only return early if the desired value is 0.1
.
Finally, the gem doesn't reset the value after the cursor is done, so it's potentially poisoning the connection settings for any other use not going through the gem.