diff --git a/lib/cafe_car/param_parser.rb b/lib/cafe_car/param_parser.rb index e7fb05d..1364a9d 100644 --- a/lib/cafe_car/param_parser.rb +++ b/lib/cafe_car/param_parser.rb @@ -38,17 +38,15 @@ def value(v) when /\.\./ a, b = v.split('..').map(&:presence).map { value(_1) } a..b - when /\A(\d*\.)?\d+\z/ - v.try(:to_f) || v when /^\$(\w+)\.(\w+)$/ $1.constantize.arel_table[$2] when Array v.map { value(_1) } when Hash - v.reject {|k, *| k.include?('.') }. - transform_values { value(_1) }. - merge(parse(v)). - tap {|h| h.merge!(h.delete('')) if h.key?('') } + v.reject {|k, *| k.include?('.') } + .transform_values { value(_1) } + .merge(parse(v)) + .tap {|h| h.merge!(h.delete('')) if h.key?('') } else v end diff --git a/lib/cafe_car/query_builder.rb b/lib/cafe_car/query_builder.rb index 74b7325..dd22dfc 100644 --- a/lib/cafe_car/query_builder.rb +++ b/lib/cafe_car/query_builder.rb @@ -20,8 +20,9 @@ def parse_time(value) def parse_value(key, value) case column(key)&.type - when :datetime - parse_time(value) || value + when :datetime then parse_time(value) || value + when :integer then value.to_i + when :float then value.to_f else value end end