Class: Arel::Visitors::IBM_DB
- Inherits:
-
Object
- Object
- Arel::Visitors::IBM_DB
- Defined in:
- lib/arel_extensions/visitors/ibm_db.rb
Instance Method Summary collapse
- #visit_ArelExtensions_Nodes_Ceil(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_DateDiff(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Duration(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_IsNull(o, collector) ⇒ Object
- #visit_ArelExtensions_Nodes_Trim(o, collector) ⇒ Object
Instance Method Details
#visit_ArelExtensions_Nodes_Ceil(o, collector) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/arel_extensions/visitors/ibm_db.rb', line 4 def visit_ArelExtensions_Nodes_Ceil o, collector collector << 'CEILING(' collector = visit o.expr, collector collector << ')' collector end |
#visit_ArelExtensions_Nodes_DateDiff(o, collector) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/arel_extensions/visitors/ibm_db.rb', line 21 def visit_ArelExtensions_Nodes_DateDiff o, collector collector << 'DAY(' collector = visit o.left, collector collector << ',' if o.right.is_a?(Arel::Attributes::Attribute) collector = visit o.right, collector else collector << "'#{o.right}'" end collector << ')' collector end |
#visit_ArelExtensions_Nodes_Duration(o, collector) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/arel_extensions/visitors/ibm_db.rb', line 34 def visit_ArelExtensions_Nodes_Duration o, collector # visit left for period if o.left == 'd' collector << 'DAY(' elsif o.left == 'm' collector << 'MONTH(' elsif o.left == 'w' collector << 'WEEK' elsif o.left == 'y' collector << 'YEAR(' end # visit right if o.right.is_a?(Arel::Attributes::Attribute) collector = visit o.right, collector else collector << "'#{o.right}'" end collector << ')' collector end |
#visit_ArelExtensions_Nodes_IsNull(o, collector) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/arel_extensions/visitors/ibm_db.rb', line 55 def visit_ArelExtensions_Nodes_IsNull o, collector collector << 'COALESCE(' collector = visit o.left, collector collector << ',' if o.right.is_a?(Arel::Attributes::Attribute) collector = visit o.right, collector else collector << "'#{o.right}'" end collector << ')' collector end |
#visit_ArelExtensions_Nodes_Trim(o, collector) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/arel_extensions/visitors/ibm_db.rb', line 11 def visit_ArelExtensions_Nodes_Trim o, collector collector << 'LTRIM(RTRIM(' o.expressions.each_with_index { |arg, i| collector << COMMA if i != 0 collector = visit arg, collector } collector << '))' collector end |