active_record-union_relation 0.3.0 → 0.4.0
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/CHANGELOG.md +15 -1
- data/lib/active_record/union_relation/version.rb +1 -1
- data/lib/active_record/union_relation.rb +18 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 894551820a6d6c88f92bf8a9c55f8970a4f878011dfa00d523d76d2b5a785162
|
4
|
+
data.tar.gz: ab39294b52ead0c9c9ecaa4fe9e41d047cc8b51ab8324188420bb80585f39511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4330bc6c675c55151260a0af99cfc71dbc6c111c4f4c46d863b96393d2a4f595bff78129303741d08be87befb297e3fa8a4393546336b1245d0c713b8aed16b5
|
7
|
+
data.tar.gz: b85793442b32beab7ba2686183a79c7b7b401a366a904b08656b25c9dcb1dc77647562899845b4008e149a28046863213188c343a3c06424dbd37b486f147a12
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.4.0] - 2025-01-04
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Support for Rails 8.
|
14
|
+
|
15
|
+
## [0.3.1] - 2024-09-19
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Fix up relations with a single source model.
|
20
|
+
|
9
21
|
## [0.3.0] - 2024-06-13
|
10
22
|
|
11
23
|
### Added
|
@@ -37,7 +49,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
37
49
|
|
38
50
|
- 🎉 Initial release. 🎉
|
39
51
|
|
40
|
-
[unreleased]: https://github.com/kddnewton/active_record-union_relation/compare/v0.
|
52
|
+
[unreleased]: https://github.com/kddnewton/active_record-union_relation/compare/v0.4.0...HEAD
|
53
|
+
[0.4.0]: https://github.com/kddnewton/active_record-union_relation/compare/v0.3.1...v0.4.0
|
54
|
+
[0.3.1]: https://github.com/kddnewton/active_record-union_relation/compare/v0.3.0...v0.3.1
|
41
55
|
[0.3.0]: https://github.com/kddnewton/active_record-union_relation/compare/v0.2.1...v0.3.0
|
42
56
|
[0.2.1]: https://github.com/kddnewton/active_record-union_relation/compare/v0.2.0...v0.2.1
|
43
57
|
[0.2.0]: https://github.com/kddnewton/active_record-union_relation/compare/v0.1.1...v0.2.0
|
@@ -3,6 +3,17 @@
|
|
3
3
|
require "active_record"
|
4
4
|
require "active_record/union_relation/version"
|
5
5
|
|
6
|
+
if defined?(ActiveRecord::Result::IndexedRow)
|
7
|
+
raise if ActiveRecord::Result::IndexedRow.method_defined?(:each)
|
8
|
+
|
9
|
+
class ActiveRecord::Result::IndexedRow
|
10
|
+
# Monkey-patch in the #each method so that we can treat it like a hash.
|
11
|
+
def each(&block)
|
12
|
+
@column_indexes.each { |column, index| yield column, @row[index] }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
6
17
|
module ActiveRecord
|
7
18
|
class UnionRelation
|
8
19
|
class Error < StandardError
|
@@ -197,9 +208,13 @@ module ActiveRecord
|
|
197
208
|
|
198
209
|
def union_for(model)
|
199
210
|
Arel::Nodes::As.new(
|
200
|
-
subqueries
|
201
|
-
.
|
202
|
-
|
211
|
+
if subqueries.one?
|
212
|
+
subqueries.first.to_arel(columns, discriminator)
|
213
|
+
else
|
214
|
+
subqueries
|
215
|
+
.map { |subquery| subquery.to_arel(columns, discriminator).ast }
|
216
|
+
.inject { |left, right| Arel::Nodes::Union.new(left, right) }
|
217
|
+
end,
|
203
218
|
Arel.sql(model.connection.quote_table_name("union"))
|
204
219
|
)
|
205
220
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-union_relation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -99,7 +99,7 @@ licenses:
|
|
99
99
|
- MIT
|
100
100
|
metadata:
|
101
101
|
bug_tracker_uri: https://github.com/kddnewton/active_record-union_relation/issues
|
102
|
-
changelog_uri: https://github.com/kddnewton/active_record-union_relation/blob/v0.
|
102
|
+
changelog_uri: https://github.com/kddnewton/active_record-union_relation/blob/v0.4.0/CHANGELOG.md
|
103
103
|
source_code_uri: https://github.com/kddnewton/active_record-union_relation
|
104
104
|
rubygems_mfa_required: 'true'
|
105
105
|
post_install_message:
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.5.
|
120
|
+
rubygems_version: 3.5.16
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Create ActiveRecord relations from UNIONs
|