# File lib/sequel/plugins/pg_array_associations.rb 144 def primary_key 145 self[:primary_key] 146 end
class Sequel::Plugins::PgArrayAssociations::ManyToPgArrayAssociationReflection
The AssociationReflection subclass for many_to_pg_array associations.
Constants
- FINALIZE_SETTINGS
Public Instance Methods
Source
# File lib/sequel/plugins/pg_array_associations.rb 80 def array_type 81 cached_fetch(:array_type) do 82 if (sch = associated_class.db_schema) && (s = sch[self[:key]]) && (t = s[:db_type]) 83 t.sub(/\[\]\z/, '').freeze 84 else 85 :integer 86 end 87 end 88 end
Source
# File lib/sequel/plugins/pg_array_associations.rb 92 def associated_object_keys 93 [self[:key]] 94 end
The array column in the associated model containing foreign keys to the current model.
Source
# File lib/sequel/plugins/pg_array_associations.rb 98 def can_have_associated_objects?(obj) 99 obj.get_column_value(self[:primary_key]) 100 end
many_to_pg_array associations can have associated objects as long as they have a primary key.
Source
# File lib/sequel/plugins/pg_array_associations.rb 104 def default_key 105 :"#{underscore(demodulize(self[:model].name))}_ids" 106 end
Assume that the key in the associated table uses a version of the current model’s name suffixed with _ids.
Source
# File lib/sequel/plugins/pg_array_associations.rb 109 def eager_graph_limit_strategy(_) 110 :ruby if self[:limit] 111 end
Always use the ruby eager_graph limit strategy if association is limited.
Source
# File lib/sequel/plugins/pg_array_associations.rb 114 def eager_limit_strategy 115 cached_fetch(:_eager_limit_strategy) do 116 :ruby if self[:limit] 117 end 118 end
Always use the ruby eager limit strategy
Source
# File lib/sequel/plugins/pg_array_associations.rb 121 def filter_by_associations_limit_strategy 122 nil 123 end
Don’t use a filter by associations limit strategy
Source
# File lib/sequel/plugins/pg_array_associations.rb 128 def finalize_settings 129 FINALIZE_SETTINGS 130 end
Source
# File lib/sequel/plugins/pg_array_associations.rb 133 def handle_silent_modification_failure? 134 self[:raise_on_save_failure] == false 135 end
Handle silent failure of add/remove methods if raise_on_save_failure is false.
Source
# File lib/sequel/plugins/pg_array_associations.rb 138 def predicate_key 139 cached_fetch(:predicate_key){qualify_assoc(self[:key_column])} 140 end
The hash key to use for the eager loading predicate (left side of IN (1, 2, 3))
Source
The column in the current table that the keys in the array column in the associated table reference.
Source
# File lib/sequel/plugins/pg_array_associations.rb 150 def remove_before_destroy? 151 false 152 end
Destroying the associated object automatically removes the association, since the association is stored in the associated object.
Private Instance Methods
Source
# File lib/sequel/plugins/pg_array_associations.rb 157 def eager_loading_predicate_condition(keys) 158 Sequel.pg_array_op(predicate_key).overlaps(Sequel.pg_array(keys, array_type)) 159 end
The predicate condition to use for the eager_loader.
Source
# File lib/sequel/plugins/pg_array_associations.rb 161 def filter_by_associations_add_conditions_dataset_filter(ds) 162 key = qualify(associated_class.table_name, self[:key]) 163 ds.cross_join(Sequel.function(:unnest, key).as(:_smtopgaa_, [:_smtopgaa_key_])).exclude(key=>nil).select(:_smtopgaa_key_) 164 end
Source
# File lib/sequel/plugins/pg_array_associations.rb 166 def filter_by_associations_conditions_key 167 qualify(self[:model].table_name, primary_key) 168 end
Source
# File lib/sequel/plugins/pg_array_associations.rb 172 def reciprocal_association?(assoc_reflect) 173 super && self[:key] == assoc_reflect[:key] && primary_key == assoc_reflect.primary_key 174 end
Only consider an association as a reciprocal if it has matching keys and primary keys.
Sequel::Model::Associations::AssociationReflection#reciprocal_association?
Source
# File lib/sequel/plugins/pg_array_associations.rb 176 def reciprocal_type 177 :pg_array_to_many 178 end
Source
# File lib/sequel/plugins/pg_array_associations.rb 180 def use_placeholder_loader? 181 false 182 end