Class: Arel::Visitors::Datastore
- Inherits:
-
ToSql
- Object
- ToSql
- Arel::Visitors::Datastore
- Defined in:
- lib/arel/visitors/datastore.rb
Defined Under Namespace
Classes: QString
Instance Method Summary collapse
- #get_limit_and_offset(o) ⇒ Object
- #insert_type_case(value) ⇒ Object
- #visit_Arel_Nodes_DeleteStatement(o) ⇒ Object
- #visit_Arel_Nodes_InsertStatement(o) ⇒ Object
- #visit_Arel_Nodes_SelectStatement(o) ⇒ Object
- #visit_Arel_Nodes_UpdateStatement(o) ⇒ Object
Instance Method Details
#get_limit_and_offset(o) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/arel/visitors/datastore.rb', line 116 def get_limit_and_offset( o ) = {} [:limit] = o.limit.expr if o.limit [:offset] = o.offset.expr if o.offset end |
#insert_type_case(value) ⇒ Object
128 129 130 |
# File 'lib/arel/visitors/datastore.rb', line 128 def insert_type_case( value ) value.is_a?( ActiveSupport::TimeWithZone ) ? value.time : value end |
#visit_Arel_Nodes_DeleteStatement(o) ⇒ Object
142 143 144 |
# File 'lib/arel/visitors/datastore.rb', line 142 def visit_Arel_Nodes_DeleteStatement o QString.new( @connection, o.relation.name ).wheres( o.wheres ) end |
#visit_Arel_Nodes_InsertStatement(o) ⇒ Object
132 133 134 135 136 |
# File 'lib/arel/visitors/datastore.rb', line 132 def visit_Arel_Nodes_InsertStatement o e = AppEngine::Datastore::Entity.new(o.relation.name) o.columns.each_with_index{|c,i| e[c.name] = insert_type_case(o.values.left[i]) } e end |
#visit_Arel_Nodes_SelectStatement(o) ⇒ Object
123 124 125 126 |
# File 'lib/arel/visitors/datastore.rb', line 123 def visit_Arel_Nodes_SelectStatement o c = o.cores.first QString.new( @connection, c.froms.name, get_limit_and_offset(o) ).wheres( c.wheres ).orders(o.orders).projections( c.projections ) end |