lib/dynamoid/criteria/chain.rb in dynamoid-1.1.0 vs lib/dynamoid/criteria/chain.rb in dynamoid-1.2.0

- old
+ new

@@ -48,26 +48,26 @@ # Destroys all the records matching the criteria. # def destroy_all ids = [] - + if key_present? ranges = [] Dynamoid.adapter.query(source.table_name, range_query).collect do |hash| ids << hash[source.hash_key.to_sym] ranges << hash[source.range_key.to_sym] end - + Dynamoid.adapter.delete(source.table_name, ids,{:range_key => ranges}) else Dynamoid.adapter.scan(source.table_name, query, scan_opts).collect do |hash| ids << hash[source.hash_key.to_sym] end - + Dynamoid.adapter.delete(source.table_name, ids) - end + end end def eval_limit(limit) @eval_limit = limit self @@ -150,25 +150,27 @@ return { :range_value => query[key] } if query[key].is_a?(Range) case key.to_s.split('.').last when 'gt' - { :range_greater_than => val.to_f } + { :range_greater_than => val } when 'lt' - { :range_less_than => val.to_f } + { :range_less_than => val } when 'gte' - { :range_gte => val.to_f } + { :range_gte => val } when 'lte' - { :range_lte => val.to_f } + { :range_lte => val } + when 'between' + { :range_between => val } when 'begins_with' { :range_begins_with => val } end end def range_query opts = { :hash_value => query[source.hash_key] } - if key = query.keys.find { |k| k.to_s.include?('.') } + query.keys.select { |k| k.to_s.include?('.') }.each do |key| opts.merge!(range_hash(key)) end opts.merge(query_opts).merge(consistent_opts) end @@ -195,10 +197,10 @@ opts[:limit] = @eval_limit if @eval_limit opts[:next_token] = start_key if @start opts[:scan_index_forward] = @scan_index_forward opts end - + def scan_opts opts = {} opts[:limit] = @eval_limit if @eval_limit opts[:next_token] = start_key if @start opts[:batch_size] = @batch_size if @batch_size