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
.
Classes and Modules
Public Class methods
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
Set the :eager_loading_predicate_transform option if not already set
# 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