Class | Sequel::Model::Associations::OneToManyAssociationReflection |
In: |
lib/sequel/model/associations.rb
|
Parent: | AssociationReflection |
Support a correlated subquery limit strategy when using eager_graph.
# File lib/sequel/model/associations.rb, line 889 889: def apply_eager_graph_limit_strategy(strategy, ds) 890: case strategy 891: when :correlated_subquery 892: apply_correlated_subquery_limit_strategy(ds) 893: else 894: super 895: end 896: end
The keys in the associated model‘s table related to this association
# File lib/sequel/model/associations.rb, line 899 899: def associated_object_keys 900: self[:keys] 901: end
one_to_many associations can only have associated objects if none of the :keys options have a nil value.
# File lib/sequel/model/associations.rb, line 905 905: def can_have_associated_objects?(obj) 906: !self[:primary_keys].any?{|k| obj.get_column_value(k).nil?} 907: end
one_to_many and one_to_one associations can be clones
# File lib/sequel/model/associations.rb, line 910 910: def cloneable?(ref) 911: ref[:type] == :one_to_many || ref[:type] == :one_to_one 912: end
Default foreign key name symbol for key in associated table that points to current table‘s primary key.
# File lib/sequel/model/associations.rb, line 916 916: def default_key 917: 918: "#{underscore(demodulize(self[:model].name))}_id" 919: end
Handle silent failure of add/remove methods if raise_on_save_failure is false.
# File lib/sequel/model/associations.rb, line 921 921: def handle_silent_modification_failure? 922: self[:raise_on_save_failure] == false 923: end
The hash key to use for the eager loading predicate (left side of IN (1, 2, 3))
# File lib/sequel/model/associations.rb, line 926 926: def predicate_key 927: cached_fetch(:predicate_key){qualify_assoc(self[:key])} 928: end
The column in the current table that the key in the associated table references.
# File lib/sequel/model/associations.rb, line 932 932: def primary_key 933: self[:primary_key] 934: end
primary_key qualified by the current table
# File lib/sequel/model/associations.rb, line 937 937: def qualified_primary_key 938: cached_fetch(:qualified_primary_key){qualify_cur(primary_key)} 939: end
Whether the reciprocal of this association returns an array of objects instead of a single object, false for a one_to_many association.
# File lib/sequel/model/associations.rb, line 943 943: def reciprocal_array? 944: false 945: end
Destroying one_to_many associated objects automatically deletes the foreign key.
# File lib/sequel/model/associations.rb, line 948 948: def remove_before_destroy? 949: false 950: end
The one_to_many association needs to check that an object to be removed already is associated.
# File lib/sequel/model/associations.rb, line 953 953: def remove_should_check_existing? 954: true 955: end