squeel 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -98,7 +98,7 @@ module Squeel
98
98
 
99
99
  order = @reorder_value ? @reorder_value : @order_values
100
100
  order = attribute_viz.accept(order.uniq.reject{|o| o.blank?})
101
- order = reverse_sql_order(sqlify_order(order)) if @reverse_order_value
101
+ order = reverse_sql_order(attrs_to_orderings(order)) if @reverse_order_value
102
102
  arel.order(*order) unless order.empty?
103
103
 
104
104
  build_select(arel, attribute_viz.accept(@select_values.uniq))
@@ -109,11 +109,11 @@ module Squeel
109
109
  arel
110
110
  end
111
111
 
112
- # reverse_sql_order doesn't understand ARel ordering nodes, so we
113
- # need to convert them to their corresponding SQL (for now)
114
- def sqlify_order(order)
112
+ # reverse_sql_order will reverse the order of strings or Orderings,
113
+ # but not attributes
114
+ def attrs_to_orderings(order)
115
115
  order.map do |o|
116
- o.respond_to?(:to_sql) ? o.to_sql : o
116
+ Arel::Attribute === o ? o.asc : o
117
117
  end
118
118
  end
119
119
 
@@ -1,3 +1,3 @@
1
1
  module Squeel
2
- VERSION = "0.8.8"
2
+ VERSION = "0.8.9"
3
3
  end
@@ -198,6 +198,12 @@ module Squeel
198
198
  end
199
199
  end
200
200
 
201
+ it 'reverses order of Arel::Attributes when #last is called' do
202
+ sorted_people = Person.all.sort {|a, b| a.name.downcase <=> b.name.downcase}
203
+
204
+ Person.order{name}.last.should eq sorted_people.last
205
+ end
206
+
201
207
  end
202
208
 
203
209
  describe '#to_sql' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squeel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-23 00:00:00.000000000Z
12
+ date: 2011-08-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70108702043340 !ruby/object:Gem::Requirement
16
+ requirement: &70295228232080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70108702043340
24
+ version_requirements: *70295228232080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70108702042780 !ruby/object:Gem::Requirement
27
+ requirement: &70295228231580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70108702042780
35
+ version_requirements: *70295228231580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70108702042220 !ruby/object:Gem::Requirement
38
+ requirement: &70295228231120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70108702042220
46
+ version_requirements: *70295228231120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: machinist
49
- requirement: &70108702041580 !ruby/object:Gem::Requirement
49
+ requirement: &70295228230660 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.6
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70108702041580
57
+ version_requirements: *70295228230660
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: faker
60
- requirement: &70108702040920 !ruby/object:Gem::Requirement
60
+ requirement: &70295228230200 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.5
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70108702040920
68
+ version_requirements: *70295228230200
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
- requirement: &70108702040300 !ruby/object:Gem::Requirement
71
+ requirement: &70295228229740 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 1.3.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70108702040300
79
+ version_requirements: *70295228229740
80
80
  description: ! "\n Squeel unlocks the power of ARel in your Rails 3 application
81
81
  with\n a handy block-based syntax. You can write subqueries, access named\n
82
82
  \ functions provided by your RDBMS, and more, all without writing\n SQL