Class Sequel::Model::Associations::ManyToOneAssociationReflection
In: lib/sequel/model/associations.rb
Parent: AssociationReflection

Methods

Public Instance methods

associated_object_keys()

Alias for primary_keys

many_to_one associations can only have associated objects if none of the :keys options have a nil value.

[Source]

     # File lib/sequel/model/associations.rb, line 740
740:         def can_have_associated_objects?(obj)
741:           !self[:keys].any?{|k| obj.get_column_value(k).nil?}
742:         end

Whether the dataset needs a primary key to function, false for many_to_one associations.

[Source]

     # File lib/sequel/model/associations.rb, line 745
745:         def dataset_need_primary_key?
746:           false
747:         end

Default foreign key name symbol for foreign key in current model‘s table that points to the given association‘s table‘s primary key.

[Source]

     # File lib/sequel/model/associations.rb, line 751
751:         def default_key
752: 
753:           "#{self[:name]}_id"
754:         end

Whether to eagerly graph a lazy dataset, true for many_to_one associations only if the key is nil.

[Source]

     # File lib/sequel/model/associations.rb, line 757
757:         def eager_graph_lazy_dataset?
758:           self[:key].nil?
759:         end

many_to_one associations don‘t need an eager_graph limit strategy

[Source]

     # File lib/sequel/model/associations.rb, line 762
762:         def eager_graph_limit_strategy(_)
763:           nil
764:         end

many_to_one associations don‘t need an eager limit strategy

[Source]

     # File lib/sequel/model/associations.rb, line 767
767:         def eager_limit_strategy
768:           nil
769:         end

many_to_one associations don‘t need a filter by associations limit strategy

[Source]

     # File lib/sequel/model/associations.rb, line 772
772:         def filter_by_associations_limit_strategy
773:           nil
774:         end

The expression to use on the left hand side of the IN lookup when eager loading

[Source]

     # File lib/sequel/model/associations.rb, line 777
777:         def predicate_key
778:           cached_fetch(:predicate_key){qualified_primary_key}
779:         end

The column(s) in the associated table that the key in the current table references (either a symbol or an array).

[Source]

     # File lib/sequel/model/associations.rb, line 782
782:         def primary_key
783:          cached_fetch(:primary_key){associated_class.primary_key || raise(Error, "no primary key specified for #{associated_class.inspect}")}
784:         end

The method symbol or array of method symbols to call on the associated object to get the value to use for the foreign keys.

[Source]

     # File lib/sequel/model/associations.rb, line 794
794:         def primary_key_method
795:          cached_fetch(:primary_key_method){primary_key}
796:         end

The array of method symbols to call on the associated object to get the value to use for the foreign keys.

[Source]

     # File lib/sequel/model/associations.rb, line 800
800:         def primary_key_methods
801:          cached_fetch(:primary_key_methods){Array(primary_key_method)}
802:         end

The columns in the associated table that the key in the current table references (always an array).

[Source]

     # File lib/sequel/model/associations.rb, line 787
787:         def primary_keys
788:          cached_fetch(:primary_keys){Array(primary_key)}
789:         end

primary_key qualified by the associated table

[Source]

     # File lib/sequel/model/associations.rb, line 805
805:         def qualified_primary_key
806:           cached_fetch(:qualified_primary_key){self[:qualify] == false ? primary_key : qualify_assoc(primary_key)}
807:         end

True only if the reciprocal is a one_to_many association.

[Source]

     # File lib/sequel/model/associations.rb, line 810
810:         def reciprocal_array?
811:           !set_reciprocal_to_self?
812:         end

Whether this association returns an array of objects instead of a single object, false for a many_to_one association.

[Source]

     # File lib/sequel/model/associations.rb, line 816
816:         def returns_array?
817:           false
818:         end

True only if the reciprocal is a one_to_one association.

[Source]

     # File lib/sequel/model/associations.rb, line 821
821:         def set_reciprocal_to_self?
822:           reciprocal
823:           reciprocal_type == :one_to_one
824:         end

[Validate]