| Class | Sequel::Plugins::PgArrayAssociations::ManyToPgArrayAssociationReflection |
| In: |
lib/sequel/plugins/pg_array_associations.rb
|
| Parent: | Sequel::Model::Associations::AssociationReflection |
The AssociationReflection subclass for many_to_pg_array associations.
| FINALIZE_SETTINGS | = | superclass::FINALIZE_SETTINGS.merge( :array_type=>:array_type |
# File lib/sequel/plugins/pg_array_associations.rb, line 80
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
The array column in the associated model containing foreign keys to the current model.
# File lib/sequel/plugins/pg_array_associations.rb, line 92
92: def associated_object_keys
93: [self[:key]]
94: end
many_to_pg_array associations can have associated objects as long as they have a primary key.
# File lib/sequel/plugins/pg_array_associations.rb, line 98
98: def can_have_associated_objects?(obj)
99: obj.get_column_value(self[:primary_key])
100: end
Assume that the key in the associated table uses a version of the current model‘s name suffixed with _ids.
# File lib/sequel/plugins/pg_array_associations.rb, line 104
104: def default_key
105:
106: "#{underscore(demodulize(self[:model].name))}_ids"
107: end
Always use the ruby eager_graph limit strategy if association is limited.
# File lib/sequel/plugins/pg_array_associations.rb, line 109
109: def eager_graph_limit_strategy(_)
110: :ruby if self[:limit]
111: end
Always use the ruby eager limit strategy
# File lib/sequel/plugins/pg_array_associations.rb, line 114
114: def eager_limit_strategy
115: cached_fetch(:_eager_limit_strategy) do
116: :ruby if self[:limit]
117: end
118: end
Don‘t use a filter by associations limit strategy
# File lib/sequel/plugins/pg_array_associations.rb, line 121
121: def filter_by_associations_limit_strategy
122: nil
123: end
# File lib/sequel/plugins/pg_array_associations.rb, line 128
128: def finalize_settings
129: FINALIZE_SETTINGS
130: end
Handle silent failure of add/remove methods if raise_on_save_failure is false.
# File lib/sequel/plugins/pg_array_associations.rb, line 133
133: def handle_silent_modification_failure?
134: self[:raise_on_save_failure] == false
135: end
The hash key to use for the eager loading predicate (left side of IN (1, 2, 3))
# File lib/sequel/plugins/pg_array_associations.rb, line 138
138: def predicate_key
139: cached_fetch(:predicate_key){qualify_assoc(self[:key_column])}
140: end
The column in the current table that the keys in the array column in the associated table reference.
# File lib/sequel/plugins/pg_array_associations.rb, line 144
144: def primary_key
145: self[:primary_key]
146: end