Module: Thredded::ArelCompat
- Defined in:
- lib/thredded/arel_compat.rb
Class Method Summary collapse
-
.integer_division(engine, a, b) ⇒ Arel::Nodes::Node
A / b.
-
.union_new(engine_or_model_class, left, right) ⇒ Arel::Nodes::Node
extract and simplified from github.com/brianhempel/active_record_union/blob/master/lib/active_record_union/active_record/relation/union.rb.
Class Method Details
.integer_division(engine, a, b) ⇒ Arel::Nodes::Node
Returns a / b.
11 12 13 14 15 16 17 |
# File 'lib/thredded/arel_compat.rb', line 11 def integer_division(engine, a, b) if /mysql|mariadb/i.match?(engine.connection.adapter_name) Arel::Nodes::InfixOperation.new('DIV', a, b) else Arel::Nodes::Division.new(a, b) end end |
.union_new(engine_or_model_class, left, right) ⇒ Arel::Nodes::Node
extract and simplified from github.com/brianhempel/active_record_union/blob/master/lib/active_record_union/active_record/relation/union.rb
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/thredded/arel_compat.rb', line 24 def union_new(engine_or_model_class, left, right) if /sqlite/i.match?(engine_or_model_class.connection.adapter_name) # Postgres allows ORDER BY in the UNION subqueries if each subquery is surrounded by parenthesis # but SQLite does not allow parens around the subqueries Arel::Nodes::Union.new(left.ast, right.ast) else # By default this adds parentheses which sqlite does not allow Arel::Nodes::Union.new(left, right) end end |