module Sequel::Plugins::PgEagerAnyTypedArray

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:

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.

Public Class Methods

apply(model) click to toggle source

Add the pg_array extension to the database

   # File lib/sequel/plugins/pg_eager_any_typed_array.rb
34 def self.apply(model)
35   model.db.extension(:pg_array)
36 end

Public Instance Methods

associate(type, name, opts = OPTS, &block) click to toggle source

Set the :eager_loading_predicate_transform option if not already set

Calls superclass method
   # File lib/sequel/plugins/pg_eager_any_typed_array.rb
83 def associate(type, name, opts = OPTS, &block)
84   res = super
85 
86   unless res.has_key?(:eager_loading_predicate_transform)
87     res[:eager_loading_predicate_transform] = TRANSFORM
88   end
89 
90   res
91 end