Module: ROM::Plugins::Relation::SQL::Postgres::Streaming
- Defined in:
- lib/rom/plugins/relation/sql/postgres/streaming.rb
Overview
PG-specific extensions which adds Relation#stream
method
Defined Under Namespace
Modules: Combined, Composite Classes: StreamingNotSupportedError
Class Method Summary collapse
Instance Method Summary collapse
-
#stream_each ⇒ Relation
Allows you to stream returned rows one at a time, instead of collecting the entire result set in memory.
Class Method Details
.apply(target, **_opts) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rom/plugins/relation/sql/postgres/streaming.rb', line 16 def self.apply(target, **_opts) conn = registry.gateways[target.config.component.gateway].connection return unless conn.database_type.to_sym == :postgres return if defined?(JRUBY_VERSION) begin require "sequel_pg" rescue LoadError raise StreamingNotSupportedError, "add sequel_pg to Gemfile to use pg_streaming" end unless Sequel::Postgres.supports_streaming? raise StreamingNotSupportedError, "postgres version does not support streaming" end conn.extension(:pg_streaming) target.include(Streaming) end |
.included(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 |
# File 'lib/rom/plugins/relation/sql/postgres/streaming.rb', line 39 def self.included(klass) super ROM::Relation::Graph.include(Combined) ROM::Relation::Composite.include(Composite) end |
Instance Method Details
#stream_each ⇒ Relation
Allows you to stream returned rows one at a time, instead of
collecting the entire result set in memory. Requires the sequel_pg
gem
57 58 59 |
# File 'lib/rom/plugins/relation/sql/postgres/streaming.rb', line 57 def stream_each raise StreamingNotSupportedError, "not supported on jruby" end |