squeel 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bd3775d68a256e08489cd4c9e80f050c9048e46
4
- data.tar.gz: d0c2141316dff16b8a0235f6ab1c8dae5224b139
3
+ metadata.gz: f09c217e5470f116d3894a55bc00252993b608ac
4
+ data.tar.gz: b53b4a457fa42594dfedee121a3f3060fbe7e6d9
5
5
  SHA512:
6
- metadata.gz: ca682a51846f17fb4f74dd5f23a10e022841b6ac91d62f744f6378a64c59fce21519b0cabf55f9dccb0a58f0b25a74592a74073d8ac67a59eb14aad7ea30cd0a
7
- data.tar.gz: 26ef0beb4f3b04d40b852cd20ed085279186aadb83718e6ebcda1e0a1b62ea5dfd63bd4f3af7f9f1365e5505893db717757409419f0fa0323bb714512c8f16a5
6
+ metadata.gz: a7455c54120d449e0a9d81c4b93afe1c6e5bdda6cf9db798b80cb91ea9d905ab2e7f16f52240cb1a022c2efab90c2669c3da1a91080114b4523eacb58b38f4a8
7
+ data.tar.gz: 12208d5ac32c0cfbb6fad4342f2a95b8260156016c2710716907c0c63de981dfb99de7a757fdc583c3472438253b4f9d0fe4095f66f7e0a6efe803c012e99126
@@ -8,31 +8,30 @@ script:
8
8
  rvm:
9
9
  - 1.9.3
10
10
  - 2.0.0
11
- - 2.1.1
12
- - 2.1.2
11
+ - 2.1.5
13
12
 
14
13
  env:
15
14
  global:
16
15
  - SQ_CONFIG_FILE=$TRAVIS_BUILD_DIR/spec/config.travis.yml
17
16
  matrix:
18
- - RAILS=master AREL=master ADAPTER=sqlite3
17
+ - RAILS=4-2-stable AREL=6-0-stable ADAPTER=sqlite3
19
18
  - RAILS=4-1-stable AREL=5-0-stable ADAPTER=sqlite3
20
19
  - RAILS=4-0-stable AREL=4-0-stable ADAPTER=sqlite3
21
20
  - RAILS=3-2-stable AREL=3-0-stable ADAPTER=sqlite3
22
21
  - RAILS=3-1-stable AREL=2-2-stable ADAPTER=sqlite3
23
22
  - RAILS=3-0-stable AREL=2-0-stable ADAPTER=sqlite3
24
- - RAILS=master AREL=master ADAPTER=mysql
23
+ - RAILS=4-2-stable AREL=6-0-stable ADAPTER=mysql
25
24
  - RAILS=4-1-stable AREL=5-0-stable ADAPTER=mysql
26
25
  - RAILS=4-0-stable AREL=4-0-stable ADAPTER=mysql
27
26
  - RAILS=3-2-stable AREL=3-0-stable ADAPTER=mysql
28
27
  - RAILS=3-1-stable AREL=2-2-stable ADAPTER=mysql
29
28
  - RAILS=3-0-stable AREL=2-0-stable ADAPTER=mysql
30
- - RAILS=master AREL=master ADAPTER=mysql2
29
+ - RAILS=4-2-stable AREL=6-0-stable ADAPTER=mysql2
31
30
  - RAILS=4-1-stable AREL=5-0-stable ADAPTER=mysql2
32
31
  - RAILS=4-0-stable AREL=4-0-stable ADAPTER=mysql2
33
32
  - RAILS=3-2-stable AREL=3-0-stable ADAPTER=mysql2
34
33
  - RAILS=3-1-stable AREL=2-2-stable ADAPTER=mysql2
35
- - RAILS=master AREL=master ADAPTER=postgresql
34
+ - RAILS=4-2-stable AREL=6-0-stable ADAPTER=postgresql
36
35
  - RAILS=4-1-stable AREL=5-0-stable ADAPTER=postgresql
37
36
  - RAILS=4-0-stable AREL=4-0-stable ADAPTER=postgresql
38
37
  - RAILS=3-2-stable AREL=3-0-stable ADAPTER=postgresql
@@ -1,4 +1,8 @@
1
- ## 1.2.3 (Unreleased)
1
+ ## 1.2.4 (Unreleased)
2
+
3
+
4
+ ## 1.2.3 (2015-2-5)
5
+ * Support the latest version of Rails 4.2 and 4.1. By @danielrhodes
2
6
 
3
7
  ## 1.2.2 (2014-11-25)
4
8
 
data/Gemfile CHANGED
@@ -3,12 +3,8 @@ gemspec
3
3
 
4
4
  gem 'rake'
5
5
 
6
- rails = ENV['RAILS'] || 'master'
7
- arel = ENV['AREL'] || 'master'
8
-
9
- if rails == 'master'
10
- gem 'i18n', github: 'svenfuchs/i18n', branch: 'master'
11
- end
6
+ rails = ENV['RAILS'] || '4-2-stable'
7
+ arel = ENV['AREL'] || '6-0-stable'
12
8
 
13
9
  arel_opts = case arel
14
10
  when /\// # A path
@@ -80,16 +80,15 @@ module Squeel
80
80
 
81
81
  collapse_wheres(arel, where_visit((where_values - ['']).uniq))
82
82
 
83
- arel.having(*having_visit(having_values.uniq.reject{|h| h.blank?})) unless having_values.empty?
83
+ arel.having(*having_visit(having_values.uniq.reject(&:blank?))) unless having_values.empty?
84
84
 
85
85
  arel.take(connection.sanitize_limit(limit_value)) if limit_value
86
86
  arel.skip(offset_value.to_i) if offset_value
87
-
88
- arel.group(*group_visit(group_values.uniq.reject{|g| g.blank?})) unless group_values.empty?
87
+ arel.group(*group_visit(group_values.uniq.reject(&:blank?))) unless group_values.empty?
89
88
 
90
89
  build_order(arel)
91
90
 
92
- build_select(arel, select_visit(select_values.uniq))
91
+ build_select(arel)
93
92
 
94
93
  arel.distinct(distinct_value)
95
94
  arel.from(build_from) if from_value
@@ -231,6 +230,14 @@ module Squeel
231
230
  arel.order(*orders) unless orders.empty?
232
231
  end
233
232
 
233
+ def build_select(arel)
234
+ if select_values.any?
235
+ arel.project(*select_visit(select_values.uniq))
236
+ else
237
+ arel.project(@klass.arel_table[Arel.star])
238
+ end
239
+ end
240
+
234
241
  def where_values_hash_with_squeel(relation_table_name = table_name)
235
242
  equalities = find_equality_predicates(where_visit(where_values), relation_table_name)
236
243
  binds = Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }]
@@ -17,6 +17,30 @@ module Squeel
17
17
  self
18
18
  end
19
19
 
20
+ def build_arel
21
+ arel = Arel::SelectManager.new(table.engine, table)
22
+
23
+ build_joins(arel, joins_values.flatten) unless joins_values.empty?
24
+
25
+ collapse_wheres(arel, where_visit((where_values - ['']).uniq))
26
+
27
+ arel.having(*having_visit(having_values.uniq.reject(&:blank?))) unless having_values.empty?
28
+
29
+ arel.take(connection.sanitize_limit(limit_value)) if limit_value
30
+ arel.skip(offset_value.to_i) if offset_value
31
+ arel.group(*group_visit(group_values.uniq.reject(&:blank?))) unless group_values.empty?
32
+
33
+ build_order(arel)
34
+
35
+ build_select(arel)
36
+
37
+ arel.distinct(distinct_value)
38
+ arel.from(build_from) if from_value
39
+ arel.lock(lock_value) if lock_value
40
+
41
+ arel
42
+ end
43
+
20
44
  def build_join_dependency(manager, joins)
21
45
  buckets = joins.group_by do |join|
22
46
  case join
@@ -89,8 +113,7 @@ module Squeel
89
113
  def expand_attrs_from_hash(opts)
90
114
  opts = ::ActiveRecord::PredicateBuilder.resolve_column_aliases(klass, opts)
91
115
 
92
- bv_len = bind_values.length
93
- tmp_opts, bind_values = create_binds(opts, bv_len)
116
+ tmp_opts, bind_values = create_binds(opts)
94
117
  self.bind_values += bind_values
95
118
 
96
119
  attributes = @klass.send(:expand_hash_conditions_for_aggregates, tmp_opts)
@@ -1,3 +1,3 @@
1
1
  module Squeel
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end
@@ -134,7 +134,12 @@ module Squeel
134
134
  })
135
135
 
136
136
  arel = relation.build_arel
137
- arel.to_sql.should match /#{Q}parents_people_2#{Q}.#{Q}name#{Q} = 'bob'/
137
+
138
+ if activerecord_version_at_least('4.2.0')
139
+ arel.to_sql.should match /#{Q}parents_people_2#{Q}.#{Q}name#{Q} = ?/
140
+ else
141
+ arel.to_sql.should match /#{Q}parents_people_2#{Q}.#{Q}name#{Q} = 'bob'/
142
+ end
138
143
  end
139
144
 
140
145
  it 'combines multiple conditions of the same type against the same column with AND' do
@@ -174,7 +179,12 @@ module Squeel
174
179
  })
175
180
 
176
181
  arel = relation.build_arel
177
- arel.to_sql.should match /HAVING #{Q}parents_people_2#{Q}.#{Q}name#{Q} = 'joe'/
182
+
183
+ if activerecord_version_at_least('4.2.0')
184
+ arel.to_sql.should match /HAVING #{Q}parents_people_2#{Q}.#{Q}name#{Q} = ?/
185
+ else
186
+ arel.to_sql.should match /HAVING #{Q}parents_people_2#{Q}.#{Q}name#{Q} = 'joe'/
187
+ end
178
188
  end
179
189
 
180
190
  it 'maps orders inside a hash to their appropriate association table' do
@@ -1053,6 +1063,20 @@ module Squeel
1053
1063
  end
1054
1064
  end
1055
1065
 
1066
+ it 'creates new records with equality predicates from has_many polymorphic associations' do
1067
+ if activerecord_version_at_least '4.2.0'
1068
+ Payment.transaction do
1069
+ seat = Seat.first
1070
+ order_item = seat.order_items.create(:quantity => 0)
1071
+ order_item.should be_persisted
1072
+ order_item.orderable_id.should eq seat.id
1073
+ order_item.orderable_type.should eq 'Seat'
1074
+ raise ::ActiveRecord::Rollback
1075
+ end
1076
+ else
1077
+ pending 'Not required in AR versions < 4.2.0'
1078
+ end
1079
+ end
1056
1080
  end
1057
1081
 
1058
1082
  describe '#where_unscoping' 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: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernie Miller
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-25 00:00:00.000000000 Z
12
+ date: 2015-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord