restful_query 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == 0.3.5 2011-08-15
2
+
3
+ * Too quick to release the last one. Fixed now.
4
+
1
5
  == 0.3.4 2011-08-15
2
6
 
3
7
  * Added support for extra options to sort. Specifically this allows you to do NULLS FIRST/LAST
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  end
10
10
 
11
11
  module RestfulQuery
12
- VERSION = '0.3.4'
12
+ VERSION = '0.3.5'
13
13
 
14
14
  class Error < RuntimeError; end
15
15
  end
@@ -10,7 +10,7 @@ module RestfulQuery
10
10
  @single_sort = options[:single_sort] || true
11
11
  @default_sort_options = options[:sort_options] || {}
12
12
  @query = (query || {}).dup
13
- @query['_sort'] ||= options[:default_sort] if options[:default_sort]
13
+ @default_sort = options[:default_sort] ? [make_sort(options[:default_sort])] : []
14
14
  @default_join = @query.delete(:join) || :and
15
15
  extract_sorts_from_conditions
16
16
  map_conditions
@@ -82,7 +82,7 @@ module RestfulQuery
82
82
  new_sort.direction = direction
83
83
  end
84
84
  else
85
- new_sort = Sort.new(column, direction)
85
+ new_sort = make_sort(column, direction)
86
86
  self.sorts << new_sort
87
87
  end
88
88
  new_sort
@@ -147,13 +147,17 @@ module RestfulQuery
147
147
  def sorts_from_hash(sorts)
148
148
  sort_conditions = [sorts].flatten.compact
149
149
  sort_conditions.collect do |c|
150
- s = Sort.parse(c)
151
- s.column = map_column(s.column)
152
- s.options = default_sort_options
153
- s
150
+ make_sort(c)
154
151
  end
155
152
  end
156
153
 
154
+ def make_sort(*condition)
155
+ s = Sort.parse(condition.flatten.join(' '))
156
+ s.column = map_column(s.column)
157
+ s.options = default_sort_options
158
+ s
159
+ end
160
+
157
161
  def columns_from_options(column_type, options)
158
162
  option = "#{column_type}_columns".to_sym
159
163
  options[option] ? [options.delete(option)].flatten.collect {|c| c.to_s } : []
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{restful_query}
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- requirement: &2152029040 !ruby/object:Gem::Requirement
17
+ requirement: &2151840860 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 2.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152029040
25
+ version_requirements: *2151840860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: chronic
28
- requirement: &2152028020 !ruby/object:Gem::Requirement
28
+ requirement: &2151839320 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.2.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152028020
36
+ version_requirements: *2151839320
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: Shoulda
39
- requirement: &2152027080 !ruby/object:Gem::Requirement
39
+ requirement: &2151837540 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 1.2.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2152027080
47
+ version_requirements: *2151837540
48
48
  description: RestfulQuery provides a simple interface in front of a complex parser
49
49
  to parse specially formatted query hashes into complex SQL queries. It includes
50
50
  ActiveRecord and Sequel extensions.