array_type()
click to toggle source
def array_type
cached_fetch(:array_type) do
if (sch = self[:model].db_schema) && (s = sch[self[:key]]) && (t = s[:db_type])
t
else
:integer
end
end
end
associated_object_keys()
click to toggle source
An array containing the primary key for the associated model.
def associated_object_keys
Array(primary_key)
end
can_have_associated_objects?(obj)
click to toggle source
pg_array_to_many associations can only have associated objects if the array
field is not nil or empty.
def can_have_associated_objects?(obj)
v = obj.get_column_value(self[:key])
v && !v.empty?
end
dataset_need_primary_key?()
click to toggle source
pg_array_to_many associations do not need a primary key.
def dataset_need_primary_key?
false
end
default_key()
click to toggle source
Use a default key name of *_ids, for similarity to other association types
that use *_id for single keys.
def default_key
:"#{singularize(self[:name])}_ids"
end
eager_graph_limit_strategy(_)
click to toggle source
Always use the ruby eager_graph limit strategy if association is limited.
def eager_graph_limit_strategy(_)
:ruby if self[:limit]
end
eager_limit_strategy()
click to toggle source
Always use the ruby eager limit strategy
def eager_limit_strategy
cached_fetch(:_eager_limit_strategy) do
:ruby if self[:limit]
end
end
filter_by_associations_conditions_expression(obj)
click to toggle source
def filter_by_associations_conditions_expression(obj)
ds = filter_by_associations_conditions_dataset.where(filter_by_associations_conditions_subquery_conditions(obj))
Sequel.function(:coalesce, Sequel.pg_array(filter_by_associations_conditions_key).overlaps(ds), Sequel::SQL::Constants::FALSE)
end
filter_by_associations_limit_strategy()
click to toggle source
Don't use a filter by associations limit strategy
def filter_by_associations_limit_strategy
nil
end
handle_silent_modification_failure?()
click to toggle source
Handle silent failure of add/remove methods if raise_on_save_failure is
false and save_after_modify is true.
def handle_silent_modification_failure?
self[:raise_on_save_failure] == false && self[:save_after_modify]
end
predicate_key()
click to toggle source
A qualified version of the associated primary key.
def predicate_key
cached_fetch(:predicate_key){qualify_assoc(primary_key)}
end
primary_key()
click to toggle source
The primary key of the associated model.
def primary_key
cached_fetch(:primary_key){associated_class.primary_key || raise(Error, "no primary key specified for #{associated_class.inspect}")}
end
primary_key_method()
click to toggle source
The method to call to get value of the primary key of the associated model.
def primary_key_method
cached_fetch(:primary_key_method){primary_key}
end