Class: Sequel::Model::Associations::OneToOneAssociationReflection
- Inherits:
-
OneToManyAssociationReflection
- Object
- Hash
- AssociationReflection
- OneToManyAssociationReflection
- Sequel::Model::Associations::OneToOneAssociationReflection
- Defined in:
- lib/sequel/model/associations.rb
Constant Summary
Constants included from Inflections
Inflections::CAMELIZE_CONVERT_REGEXP, Inflections::CAMELIZE_MODULE_REGEXP, Inflections::DASH, Inflections::DEMODULIZE_CONVERT_REGEXP, Inflections::EMPTY_STRING, Inflections::SLASH, Inflections::UNDERSCORE, Inflections::UNDERSCORE_CONVERT_REGEXP1, Inflections::UNDERSCORE_CONVERT_REGEXP2, Inflections::UNDERSCORE_CONVERT_REPLACE, Inflections::UNDERSCORE_MODULE_REGEXP, Inflections::VALID_CONSTANT_NAME_REGEXP
Instance Method Summary collapse
-
#eager_limit_strategy ⇒ Object
one_to_one associations don’t use an eager limit strategy by default, but support both DISTINCT ON and window functions as strategies.
-
#limit_and_offset ⇒ Object
The limit and offset for this association (returned as a two element array).
-
#returns_array? ⇒ Boolean
one_to_one associations return a single object, not an array.
Methods inherited from OneToManyAssociationReflection
#associated_object_keys, #can_have_associated_objects?, #default_key, #predicate_key, #primary_key, #qualified_primary_key, #reciprocal_array?, #remove_before_destroy?, #remove_should_check_existing?, #set_reciprocal_to_self?
Methods inherited from AssociationReflection
#_add_method, #_remove_all_method, #_remove_method, #_setter_method, #add_method, #apply_dataset_changes, #associated_class, #associated_dataset, #association_method, #can_have_associated_objects?, #dataset_method, #dataset_need_primary_key?, #eager_graph_lazy_dataset?, #eager_loader_key, #eager_loading_predicate_key, #eager_loading_use_associated_key?, #need_associated_primary_key?, #predicate_keys, #qualify, #qualify_assoc, #qualify_cur, #reciprocal, #reciprocal_array?, #remove_all_method, #remove_before_destroy?, #remove_method, #remove_should_check_existing?, #select, #set_reciprocal_to_self?, #setter_method, #slice_range
Methods included from Inflections
clear, irregular, plural, singular, uncountable
Methods inherited from Hash
#&, #case, #hstore, #pg_json, #sql_expr, #sql_negate, #sql_or, #|, #~
Instance Method Details
#eager_limit_strategy ⇒ Object
one_to_one associations don’t use an eager limit strategy by default, but support both DISTINCT ON and window functions as strategies.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/sequel/model/associations.rb', line 483 def eager_limit_strategy cached_fetch(:_eager_limit_strategy) do offset = limit_and_offset.last case s = self.fetch(:eager_limit_strategy){(self[:model].default_eager_limit_strategy || :ruby) if offset} when Symbol s when true ds = associated_class.dataset if ds.supports_ordered_distinct_on? && offset.nil? :distinct_on elsif ds.supports_window_functions? :window_function else :ruby end else nil end end end |
#limit_and_offset ⇒ Object
The limit and offset for this association (returned as a two element array).
505 506 507 508 509 510 511 |
# File 'lib/sequel/model/associations.rb', line 505 def limit_and_offset if (v = self[:limit]).is_a?(Array) v else [v, nil] end end |
#returns_array? ⇒ Boolean
one_to_one associations return a single object, not an array
514 515 516 |
# File 'lib/sequel/model/associations.rb', line 514 def returns_array? false end |