Class: Arel::SelectManager
- Inherits:
-
TreeManager
- Object
- TreeManager
- Arel::SelectManager
- Defined in:
- lib/arel/visitors/sqlserver.rb
Instance Method Summary collapse
-
#lock(locking = true) ⇒ Object
A friendly over ride that allows us to put a special lock object that can have a default or pass custom string hints down.
- #lock_without_sqlserver ⇒ Object
- #order(*exprs) ⇒ Object
-
#order_without_sqlserver ⇒ Object
Getting real Ordering objects is very important for us.
Instance Method Details
#lock(locking = true) ⇒ Object
A friendly over ride that allows us to put a special lock object that can have a default or pass custom string hints down. See the visit_Arel_Nodes_LockWithSQLServer delegation method.
61 62 63 64 65 66 67 68 |
# File 'lib/arel/visitors/sqlserver.rb', line 61 def lock(locking=true) if Arel::Visitors::SQLServer === @visitor @ast.lock = Arel::Nodes::LockWithSQLServer.new(locking) self else lock_without_sqlserver(locking) end end |
#lock_without_sqlserver ⇒ Object
29 |
# File 'lib/arel/visitors/sqlserver.rb', line 29 alias :lock_without_sqlserver :lock |
#order(*exprs) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/arel/visitors/sqlserver.rb', line 36 def order(*exprs) return order_without_sqlserver(*exprs) unless Arel::Visitors::SQLServer === @visitor @ast.orders.concat(exprs.map{ |x| case x when Arel::Attributes::Attribute table = Arel::Table.new(x.relation.table_alias || x.relation.name) expr = table[x.name] Arel::Nodes::Ordering.new expr when String x.split(',').map do |s| expr, direction = s.split expr = Arel.sql(expr) direction = direction =~ /desc/i ? :desc : :asc Arel::Nodes::Ordering.new expr, direction end else expr = Arel.sql(x.to_s) Arel::Nodes::Ordering.new expr end }.flatten) self end |
#order_without_sqlserver ⇒ Object
Getting real Ordering objects is very important for us. We need to be able to call #uniq on a colleciton of them reliably as well as using their true object attributes to mutate them to grouping objects for the inner sql during a select statment with an offset/rownumber. So this is here till ActiveRecord & ARel does this for us instead of using SqlLiteral objects.
35 |
# File 'lib/arel/visitors/sqlserver.rb', line 35 alias :order_without_sqlserver :order |