Module: Sequel::Plugins::PgEagerAnyTypedArray

Defined in:
lib/sequel/plugins/pg_eager_any_typed_array.rb

Overview

The pg_eager_any_typed_array plugin automatically converts the predicate expressions used for eager loading from:

table.column IN (value_list)

to:

table.column = ANY(array_expr::type[])

This makes it easier to use the pg_auto_parameterize_in_array extension with the :treat_string_list_as_text_array option, when using foreign keys with non-text database types that are represented by Ruby strings, such as enum and uuid types.

Most association types that ship with Sequel have their predicate expressions converted by this plugin. Here are the exceptions:

  • associations using composite predicate keys

  • many_to_pg_array associations

  • many_to_many/one_through_one associations using :join_table_db option

  • many_through_many/one_through_many associations using :separate_table_per_query option

To avoid predicate conversion for particular associations, set the :eager_loading_predicate_transform association option to nil/false.

This plugin loads the pg_array extension into the model’s Database.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.apply(model) ⇒ Object

Add the pg_array extension to the database

[View source]

34
35
36
# File 'lib/sequel/plugins/pg_eager_any_typed_array.rb', line 34

def self.apply(model)
  model.db.extension(:pg_array)
end