baby_squeel 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/baby_squeel/nodes/attribute.rb +19 -3
- data/lib/baby_squeel/version.rb +1 -1
- 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: 3a93b2e6f4683805f7d23a2b7ce9ac30756052ac
|
4
|
+
data.tar.gz: 4179fa1811a17756568b82758ae9fa02267d3f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e61f2a56c95418acbbd6abdad4aaf942cdb86f2ae88703e3a9ede99c8e133716145ce2b2d19109c2328c7aa208d5637fecb9478557e4d4492c78e31244323b5
|
7
|
+
data.tar.gz: 7b2b9836c944357c7e181baa5a463fc9948eabe2e4d30a6d9a1c135f38a61a5ef33df1fb9c4d5372baef6b660c3ecb280a3f313ea1ae1814cdcff419d574e42b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Nothing to see here.
|
4
4
|
|
5
|
+
## [1.1.4] - 2017-04-13
|
6
|
+
### Fixed
|
7
|
+
- Nodes::Attribute#in and #not_in generate valid SQL when given ActiveRecord::NullRelations.
|
8
|
+
|
5
9
|
## [1.1.3] - 2017-03-31
|
6
10
|
### Fixed
|
7
11
|
- Nodes::Attribute#in was not returning BabySqueel node. As a result, you couldn't chain on it. This fixes #61.
|
@@ -114,7 +118,8 @@ Nothing to see here.
|
|
114
118
|
### Added
|
115
119
|
- Initial support for selects, orders, wheres, and joins.
|
116
120
|
|
117
|
-
[Unreleased]: https://github.com/rzane/baby_squeel/compare/v1.1.
|
121
|
+
[Unreleased]: https://github.com/rzane/baby_squeel/compare/v1.1.4...HEAD
|
122
|
+
[1.1.3]: https://github.com/rzane/baby_squeel/compare/v1.1.3...v1.1.4
|
118
123
|
[1.1.3]: https://github.com/rzane/baby_squeel/compare/v1.1.2...v1.1.3
|
119
124
|
[1.1.2]: https://github.com/rzane/baby_squeel/compare/v1.1.1...v1.1.2
|
120
125
|
[1.1.1]: https://github.com/rzane/baby_squeel/compare/v1.1.0...v1.1.1
|
@@ -11,8 +11,7 @@ module BabySqueel
|
|
11
11
|
|
12
12
|
def in(rel)
|
13
13
|
if rel.is_a? ::ActiveRecord::Relation
|
14
|
-
|
15
|
-
Nodes.wrap ::Arel::Nodes::In.new(self, expr)
|
14
|
+
Nodes.wrap ::Arel::Nodes::In.new(self, sanitize_relation(rel))
|
16
15
|
else
|
17
16
|
super
|
18
17
|
end
|
@@ -20,7 +19,7 @@ module BabySqueel
|
|
20
19
|
|
21
20
|
def not_in(rel)
|
22
21
|
if rel.is_a? ::ActiveRecord::Relation
|
23
|
-
::Arel::Nodes::NotIn.new(self,
|
22
|
+
Nodes.wrap ::Arel::Nodes::NotIn.new(self, sanitize_relation(rel))
|
24
23
|
else
|
25
24
|
super
|
26
25
|
end
|
@@ -33,6 +32,23 @@ module BabySqueel
|
|
33
32
|
super
|
34
33
|
end
|
35
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# NullRelation must be treated as a special case, because
|
39
|
+
# NullRelation#to_sql returns an empty string. As such,
|
40
|
+
# we need to convert the NullRelation to regular relation.
|
41
|
+
# Conveniently, this approach automatically adds a 1=0.
|
42
|
+
# I have literally no idea why, but I'll take it.
|
43
|
+
def sanitize_relation(rel)
|
44
|
+
if rel.kind_of? ::ActiveRecord::NullRelation
|
45
|
+
other = rel.spawn
|
46
|
+
other.extending_values -= [::ActiveRecord::NullRelation]
|
47
|
+
sanitize_relation rel.unscoped.merge(other)
|
48
|
+
else
|
49
|
+
Arel.sql rel.to_sql
|
50
|
+
end
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
data/lib/baby_squeel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baby_squeel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|