Module: Torque::PostgreSQL::Reflection::AbstractReflection
- Defined in:
- lib/torque/postgresql/reflection/abstract_reflection.rb
Constant Summary collapse
- AREL_ATTR =
::Arel::Attributes::Attribute
- AREL_NODE =
::Arel::Nodes::Node
Instance Method Summary collapse
-
#build_join_constraint(table, foreign_table) ⇒ Object
Manually build the join constraint.
-
#connected_through_array? ⇒ Boolean
Check if the foreign key actually exists.
-
#join_scope(table, foreign_table, foreign_klass) ⇒ Object
Connection through an array-like attribute is more complex then just a simple eq.
Instance Method Details
#build_join_constraint(table, foreign_table) ⇒ Object
Manually build the join constraint
31 32 33 34 35 36 37 |
# File 'lib/torque/postgresql/reflection/abstract_reflection.rb', line 31 def build_join_constraint(table, foreign_table) result = build_id_constraint_between(table, foreign_table) result = table.create_and([result, klass.send(:type_condition, table)]) \ if klass.finder_needs_type_condition? result end |
#connected_through_array? ⇒ Boolean
Check if the foreign key actually exists
11 12 13 |
# File 'lib/torque/postgresql/reflection/abstract_reflection.rb', line 11 def connected_through_array? false end |
#join_scope(table, foreign_table, foreign_klass) ⇒ Object
Connection through an array-like attribute is more complex then just a simple eq. This needs to go through the channel that handles larger situations
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/torque/postgresql/reflection/abstract_reflection.rb', line 18 def join_scope(table, foreign_table, foreign_klass) return super unless connected_through_array? table_md = ActiveRecord::TableMetadata.new(klass, table) predicate_builder = klass.predicate_builder.with(table_md) scope_chain_items = join_scopes(table, predicate_builder) klass_scope = klass_join_scope(table, predicate_builder) klass_scope.where!(build_id_constraint_between(table, foreign_table)) scope_chain_items.inject(klass_scope, &:merge!) end |