squeel 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -6
- data/lib/squeel/adapters/active_record/4.1/relation_extensions.rb +11 -4
- data/lib/squeel/adapters/active_record/4.2/relation_extensions.rb +25 -2
- data/lib/squeel/version.rb +1 -1
- data/spec/squeel/adapters/active_record/relation_extensions_spec.rb +26 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f09c217e5470f116d3894a55bc00252993b608ac
|
4
|
+
data.tar.gz: b53b4a457fa42594dfedee121a3f3060fbe7e6d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7455c54120d449e0a9d81c4b93afe1c6e5bdda6cf9db798b80cb91ea9d905ab2e7f16f52240cb1a022c2efab90c2669c3da1a91080114b4523eacb58b38f4a8
|
7
|
+
data.tar.gz: 12208d5ac32c0cfbb6fad4342f2a95b8260156016c2710716907c0c63de981dfb99de7a757fdc583c3472438253b4f9d0fe4095f66f7e0a6efe803c012e99126
|
data/.travis.yml
CHANGED
@@ -8,31 +8,30 @@ script:
|
|
8
8
|
rvm:
|
9
9
|
- 1.9.3
|
10
10
|
- 2.0.0
|
11
|
-
- 2.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=
|
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=
|
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=
|
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=
|
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
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -3,12 +3,8 @@ gemspec
|
|
3
3
|
|
4
4
|
gem 'rake'
|
5
5
|
|
6
|
-
rails = ENV['RAILS'] || '
|
7
|
-
arel = ENV['AREL'] || '
|
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
|
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
|
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
|
-
|
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)
|
data/lib/squeel/version.rb
CHANGED
@@ -134,7 +134,12 @@ module Squeel
|
|
134
134
|
})
|
135
135
|
|
136
136
|
arel = relation.build_arel
|
137
|
-
|
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
|
-
|
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.
|
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:
|
12
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|