active_record_union 1.0.1 → 1.1.0

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: de7279017756c9ab6fa65a13d457b671d4d3fc1f
4
- data.tar.gz: a059566a08659d432635c1ad707431a3b8c163a1
3
+ metadata.gz: 0e5aaf90d66c3e15eb7e2c225283b0c2790b146b
4
+ data.tar.gz: fb36ac1c86da58e19de86409e9bd3c35897e247f
5
5
  SHA512:
6
- metadata.gz: bc0aae94fd243b66458b8ad719833bea64c69be694eaa5a73e370c3aea1dd918b74e15463b8c03b7d5c7d808db526bc0de3b06f27e8d27087e1678c0d0441b70
7
- data.tar.gz: 0481dcf3092a0e166bcca93da7e9b1634d999cdecfd7ef14d108ab95ab2c291c9d8cf8e77f232b946da5beba0aec78ecb2036abaa5536668656655af6f908a0e
6
+ metadata.gz: 3b0140dffec59d1214dc18c456dad0ff28c24f1262704ab7628af0f679dc08c5e30d9d8effcbff29fa4f6800894579b82f2663d15a1341b895512546f366c109
7
+ data.tar.gz: 9683ecd6bd506d3226a04ddb3abcd461a7a3adb0088d0f577069569965bac460480bf35f5dd26fcf966779a24a0f1cb32cf531e5c8600dea86769ec540416c26
@@ -1,3 +1,3 @@
1
1
  ActiveRecordUnion is dedicated to the public domain by its author, Brian Hempel. No rights are reserved. No restrictions are placed on the use of ActiveRecordUnion. That freedom also means, of course, that no warrenty of fitness is claimed; use ActiveRecordUnion at your own risk.
2
2
 
3
- Public domain dedication is explained by the CC0 1.0 summary (and only the summary) at https://creativecommons.org/publicdomain/zero/1.0/
3
+ This public domain dedication follows the the CC0 1.0 at https://creativecommons.org/publicdomain/zero/1.0/
data/README.md CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
- ActiveRecordUnion adds a `union` method to `ActiveRecord::Relation` so we can easily gather together queries on mutiple scopes.
28
+ ActiveRecordUnion adds `union` and `union_all` methods to `ActiveRecord::Relation` so we can easily gather together queries on mutiple scopes.
29
29
 
30
30
  Consider some users with posts:
31
31
 
@@ -48,11 +48,11 @@ With ActiveRecordUnion, we can do:
48
48
  current_user.posts.union(Post.published)
49
49
  ```
50
50
 
51
- Which is equivalent to the following SQL: [<a href="#footnote-1">1</a>]
51
+ Which is equivalent to the following SQL:
52
52
 
53
53
  ```sql
54
54
  SELECT "posts".* FROM (
55
- SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ?
55
+ SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
56
56
  UNION
57
57
  SELECT "posts".* FROM "posts" WHERE (published_at < '2014-07-19 16:04:21.918366')
58
58
  ) posts
@@ -65,13 +65,13 @@ current_user.posts.union(Post.published).where(id: [6, 7])
65
65
  ```
66
66
  ```sql
67
67
  SELECT "posts".* FROM (
68
- SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ?
68
+ SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
69
69
  UNION
70
70
  SELECT "posts".* FROM "posts" WHERE (published_at < '2014-07-19 16:06:04.460771')
71
71
  ) posts WHERE "posts"."id" IN (6, 7)
72
72
  ```
73
73
 
74
- The `union` method can also accepts anything that `where` does.
74
+ The `union` method can also accept anything that `where` does.
75
75
 
76
76
  ```ruby
77
77
  current_user.posts.union("published_at < ?", Time.now)
@@ -89,16 +89,29 @@ user_1.posts.union(user_2.posts).union(Post.published)
89
89
  ```sql
90
90
  SELECT "posts".* FROM (
91
91
  SELECT "posts".* FROM (
92
- SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ?
92
+ SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
93
93
  UNION
94
- SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ?
94
+ SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 2
95
95
  ) posts
96
96
  UNION
97
97
  SELECT "posts".* FROM "posts" WHERE (published_at < '2014-07-19 16:12:45.882648')
98
98
  ) posts
99
99
  ```
100
100
 
101
- <a name="footnote-1"></a>[1] Note: the `?` in the SQL is bound to the correct value when ActiveRecord executes the query. Also, the SQL examples here were generated for a SQLite database. The syntax generated for other databases may vary slightly.
101
+ ### UNION ALL
102
+
103
+ By default, UNION will remove any duplicates from the result set. If you don't care about duplicates or you know that the two queries you are combining will not have duplicates, you call use UNION ALL to tell the database to skip its deduplication step. In some cases this can give significant performance improvements.
104
+
105
+ ```ruby
106
+ user_1.posts.union_all(user_2.posts)
107
+ ```
108
+ ```sql
109
+ SELECT "posts".* FROM (
110
+ SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
111
+ UNION ALL
112
+ SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 2
113
+ ) posts
114
+ ```
102
115
 
103
116
  ## Caveats
104
117
 
@@ -118,11 +131,11 @@ current_user.posts.where(id: other_user.favorited_posts)
118
131
  ```
119
132
  ```sql
120
133
  SELECT "posts".* FROM "posts"
121
- WHERE "posts"."user_id" = ?
134
+ WHERE "posts"."user_id" = 1
122
135
  AND "posts"."id" IN (
123
136
  SELECT "posts"."id"
124
137
  FROM "posts" INNER JOIN "user_favorited_posts" ON "posts"."id" = "user_favorited_posts"."post_id"
125
- WHERE "user_favorited_posts"."user_id" = ?
138
+ WHERE "user_favorited_posts"."user_id" = 2
126
139
  )
127
140
  ```
128
141
 
@@ -133,7 +146,7 @@ current_user.posts.where(id: UserFavoritedPost.where(user_id: other_user.id).sel
133
146
  ```
134
147
  ```sql
135
148
  SELECT "posts".* FROM "posts"
136
- WHERE "posts"."user_id" = ?
149
+ WHERE "posts"."user_id" = 1
137
150
  AND "posts"."id" IN (
138
151
  SELECT "user_favorited_posts"."post_id"
139
152
  FROM "user_favorited_posts"
@@ -149,7 +162,7 @@ Why does this gem exist?
149
162
 
150
163
  Right now in ActiveRecord, if we call `scope.union` we get an `Arel::Nodes::Union` object instead of an `ActiveRecord::Relation`.
151
164
 
152
- We could call `to_sql` on the Arel object and then use `find_by_sql`, but that's not super clean and if the original scopes included an association, then the `to_sql` may produce a query with values that need to be bound (represented by `?`s in the SQL) and we have to provide those ourselves. (E.g. `user.posts.to_sql` produces `SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ?`.)
165
+ We could call `to_sql` on the Arel object and then use `find_by_sql`, but that's not super clean. Also, on Rails 4.0 and 4.1 if the original scopes included an association then the `to_sql` may produce a query with values that need to be bound (represented by `?`s in the SQL) and we have to provide those ourselves. (E.g. `user.posts.to_sql` produces `SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = ?`.) Rails 4.2's `to_sql` replaces the bind values before showing the SQL string and thus can more readily be used with `find_by_sql`. (E.g. Rails 4.2 `to_sql` would say `WHERE "posts"."user_id" = 1` instead of `WHERE "posts"."user_id" = ?`.)
153
166
 
154
167
  While ActiveRecord may eventually have the ability to cleanly perform UNIONs, it's currently stalled. If you're interested, the relevant URLs as of July 2014 are:
155
168
 
@@ -161,6 +174,8 @@ This is a gem not a Rails pull request because the standard of code quality for
161
174
 
162
175
  ## Changelog
163
176
 
177
+ **1.1.0** - Mar 29, 2015 - Add UNION ALL support, courtesy of [@pic](https://github.com/pic).
178
+
164
179
  **1.0.1** - Sept 2, 2014 - Allow ORDER BY in UNION subselects for databases that support it (not SQLite).
165
180
 
166
181
  **1.0.0** - July 24, 2014 - Initial release.
@@ -169,11 +184,11 @@ This is a gem not a Rails pull request because the standard of code quality for
169
184
 
170
185
  ActiveRecordUnion is dedicated to the public domain by its author, Brian Hempel. No rights are reserved. No restrictions are placed on the use of ActiveRecordUnion. That freedom also means, of course, that no warrenty of fitness is claimed; use ActiveRecordUnion at your own risk.
171
186
 
172
- Public domain dedication is explained by the CC0 1.0 summary (and only the summary) at https://creativecommons.org/publicdomain/zero/1.0/
187
+ This public domain dedication follows the the CC0 1.0 at https://creativecommons.org/publicdomain/zero/1.0/
173
188
 
174
189
  ## Contributing
175
190
 
176
- 1. Fork it ( https://github.com/[my-github-username]/active_record_union/fork )
191
+ 1. Fork it ( https://github.com/brianhempel/active_record_union/fork )
177
192
  2. Create your feature branch (`git checkout -b my-new-feature`)
178
193
  3. Run the tests with `rspec`
179
194
  4. There is also a `bin/console` command to load up a REPL for playing around
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ActiveRecordUnion::VERSION
9
9
  spec.authors = ["Brian Hempel"]
10
10
  spec.email = ["plasticchicken@gmail.com"]
11
- spec.summary = %q{UNIONs in ActiveRecord! Adds a proper union method to ActiveRecord::Relation.}
11
+ spec.summary = %q{UNIONs in ActiveRecord! Adds proper union and union_all methods to ActiveRecord::Relation.}
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "https://github.com/brianhempel/active_record_union"
14
14
  spec.license = "Public Domain"
@@ -1,11 +1,30 @@
1
1
  module ActiveRecord
2
2
  class Relation
3
3
  module Union
4
- def union(relation_or_where_arg, *args)
5
- other = relation_or_where_arg if args.size == 0 && Relation === relation_or_where_arg
6
- other ||= @klass.where(relation_or_where_arg, *args)
7
4
 
8
- verify_union_relations!(self, other)
5
+ SET_OPERATION_TO_AREL_CLASS = {
6
+ "UNION" => Arel::Nodes::Union,
7
+ "UNION ALL" => Arel::Nodes::UnionAll
8
+ }
9
+
10
+ def union(relation_or_where_arg, *args)
11
+ set_operation("UNION", relation_or_where_arg, *args)
12
+ end
13
+
14
+ def union_all(relation_or_where_arg, *args)
15
+ set_operation("UNION ALL", relation_or_where_arg, *args)
16
+ end
17
+
18
+ private
19
+
20
+ def set_operation(operation, relation_or_where_arg, *args)
21
+ other = if args.size == 0 && Relation === relation_or_where_arg
22
+ relation_or_where_arg
23
+ else
24
+ @klass.where(relation_or_where_arg, *args)
25
+ end
26
+
27
+ verify_relations_for_set_operation!(operation, self, other)
9
28
 
10
29
  # Postgres allows ORDER BY in the UNION subqueries if each subquery is surrounded by parenthesis
11
30
  # but SQLite does not allow parens around the subqueries; you will have to explicitly do `relation.reorder(nil)` in SQLite
@@ -15,9 +34,9 @@ module ActiveRecord
15
34
  left, right = Arel::Nodes::Grouping.new(self.ast), Arel::Nodes::Grouping.new(other.ast)
16
35
  end
17
36
 
18
- union = Arel::Nodes::Union.new(left, right)
37
+ set = SET_OPERATION_TO_AREL_CLASS[operation].new(left, right)
19
38
  from = Arel::Nodes::TableAlias.new(
20
- union,
39
+ set,
21
40
  Arel::Nodes::SqlLiteral.new(@klass.arel_table.name)
22
41
  )
23
42
 
@@ -26,22 +45,21 @@ module ActiveRecord
26
45
  relation
27
46
  end
28
47
 
29
- private
48
+ def verify_relations_for_set_operation!(operation, *relations)
49
+ includes_relations = relations.select { |r| r.includes_values.any? }
30
50
 
31
- def verify_union_relations!(*args)
32
- includes_relations = args.select { |r| r.includes_values.any? }
33
51
  if includes_relations.any?
34
- raise ArgumentError.new("Cannot union relation with includes.")
52
+ raise ArgumentError.new("Cannot #{operation} relation with includes.")
35
53
  end
36
54
 
37
- preload_relations = args.select { |r| r.preload_values.any? }
55
+ preload_relations = relations.select { |r| r.preload_values.any? }
38
56
  if preload_relations.any?
39
- raise ArgumentError.new("Cannot union relation with preload.")
57
+ raise ArgumentError.new("Cannot #{operation} relation with preload.")
40
58
  end
41
59
 
42
- eager_load_relations = args.select { |r| r.eager_load_values.any? }
60
+ eager_load_relations = relations.select { |r| r.eager_load_values.any? }
43
61
  if eager_load_relations.any?
44
- raise ArgumentError.new("Cannot union relation with eager load.")
62
+ raise ArgumentError.new("Cannot #{operation} relation with eager load.")
45
63
  end
46
64
  end
47
65
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordUnion
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -8,7 +8,7 @@ end unless defined?(User)
8
8
  ActiveRecord::Base.connection.create_table :posts, force: true do |t|
9
9
  t.integer :user_id
10
10
  t.timestamp :published_at
11
- t.timestamps
11
+ t.timestamps null: false
12
12
  end
13
13
 
14
14
  class Post < ActiveRecord::Base
@@ -26,10 +26,13 @@ describe ActiveRecord::Relation do
26
26
  end
27
27
 
28
28
  it "works" do
29
- union = User.new.posts.union(Post.where("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0)))
29
+ union = User.new(id: 1).posts.union(Post.where("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0)))
30
30
 
31
- expect(union.to_sql).to eq(
32
- "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
31
+ expect(union.to_sql.squish).to eq(
32
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
33
+ )
34
+ expect(union.arel.to_sql.squish).to eq(
35
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
33
36
  )
34
37
  expect{union.to_a}.to_not raise_error
35
38
  end
@@ -53,25 +56,25 @@ describe ActiveRecord::Relation do
53
56
  default_scope { where("published_at < ?", Time.now) }
54
57
  end
55
58
 
56
- union = PublishedPost.where("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0)).union(User.new.posts)
59
+ union = PublishedPost.where("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0)).union(User.new(id: 1).posts)
57
60
 
58
- expect(union.to_sql).to eq(
59
- "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE (published_at < '2014-07-24 00:00:00.000000') AND (created_at > '2014-07-19 00:00:00.000000') UNION SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? ) posts"
61
+ expect(union.to_sql.squish).to eq(
62
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE (published_at < '2014-07-24 00:00:00.000000') AND (created_at > '2014-07-19 00:00:00.000000') UNION SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 ) posts"
60
63
  )
61
64
  expect{union.to_a}.to_not raise_error
62
65
  end
63
66
 
64
67
  context "with ORDER BY in subselects" do
65
68
  def union
66
- User.new.posts.order(:created_at).union(
69
+ User.new(id: 1).posts.order(:created_at).union(
67
70
  Post.where("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0)).order(:created_at)
68
71
  ).order(:created_at)
69
72
  end
70
73
 
71
74
  context "in SQLite" do
72
75
  it "lets ORDER BY in query subselects throw a syntax error" do
73
- expect(union.to_sql).to eq(
74
- "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? ORDER BY \"posts\".\"created_at\" ASC UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ORDER BY \"posts\".\"created_at\" ASC ) posts ORDER BY \"posts\".\"created_at\" ASC"
76
+ expect(union.to_sql.squish).to eq(
77
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 ORDER BY \"posts\".\"created_at\" ASC UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ORDER BY \"posts\".\"created_at\" ASC ) posts ORDER BY \"posts\".\"created_at\" ASC"
75
78
  )
76
79
  expect{union.to_a}.to raise_error(ActiveRecord::StatementInvalid)
77
80
  end
@@ -80,8 +83,8 @@ describe ActiveRecord::Relation do
80
83
  context "in Postgres" do
81
84
  it "wraps query subselects in parentheses to allow ORDER BY clauses" do
82
85
  Databases.with_postgres do
83
- expect(union.to_sql).to eq(
84
- "SELECT \"posts\".* FROM ( (SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = $1 ORDER BY \"posts\".\"created_at\" ASC) UNION (SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ORDER BY \"posts\".\"created_at\" ASC) ) posts ORDER BY \"posts\".\"created_at\" ASC"
86
+ expect(union.to_sql.squish).to eq(
87
+ "SELECT \"posts\".* FROM ( (SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = $1 ORDER BY \"posts\".\"created_at\" ASC) UNION (SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ORDER BY \"posts\".\"created_at\" ASC) ) posts ORDER BY \"posts\".\"created_at\" ASC"
85
88
  )
86
89
  expect{union.to_a}.to_not raise_error
87
90
  end
@@ -91,7 +94,7 @@ describe ActiveRecord::Relation do
91
94
  context "in MySQL" do
92
95
  it "wraps query subselects in parentheses to allow ORDER BY clauses" do
93
96
  Databases.with_mysql do
94
- expect(union.to_sql).to eq(
97
+ expect(union.to_sql.squish).to eq(
95
98
  "SELECT \"posts\".* FROM ( (SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = $1 ORDER BY \"posts\".\"created_at\" ASC) UNION (SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ORDER BY \"posts\".\"created_at\" ASC) ) posts ORDER BY \"posts\".\"created_at\" ASC"
96
99
  )
97
100
  expect{union.to_a}.to_not raise_error
@@ -102,28 +105,39 @@ describe ActiveRecord::Relation do
102
105
 
103
106
  context "builds a scope when given" do
104
107
  it "a hash" do
105
- union = User.new.posts.union(id: 1)
108
+ union = User.new(id: 1).posts.union(id: 2)
106
109
 
107
- expect(union.to_sql).to eq(
108
- "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = 1 ) posts"
110
+ expect(union.to_sql.squish).to eq(
111
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = 2 ) posts"
109
112
  )
110
113
  end
111
114
 
112
115
  it "multiple arguments" do
113
- union = User.new.posts.union("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0))
116
+ union = User.new(id: 1).posts.union("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0))
114
117
 
115
- expect(union.to_sql).to eq(
116
- "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
118
+ expect(union.to_sql.squish).to eq(
119
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
117
120
  )
118
121
  end
119
122
 
120
123
  it "arel" do
121
- union = User.new.posts.union(Post.arel_table[:id].eq(1).or(Post.arel_table[:id].eq(2)))
124
+ union = User.new(id: 1).posts.union(Post.arel_table[:id].eq(2).or(Post.arel_table[:id].eq(3)))
122
125
 
123
- expect(union.to_sql).to eq(
124
- "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE ((\"posts\".\"id\" = 1 OR \"posts\".\"id\" = 2)) ) posts"
126
+ expect(union.to_sql.squish).to eq(
127
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE (\"posts\".\"id\" = 2 OR \"posts\".\"id\" = 3) ) posts"
125
128
  )
126
129
  end
127
130
  end
128
131
  end
132
+
133
+ describe ".union_all" do
134
+ it "works" do
135
+ union = User.new(id: 1).posts.union_all(Post.where("created_at > ?", Time.utc(2014, 7, 19, 0, 0, 0)))
136
+
137
+ expect(union.to_sql.squish).to eq(
138
+ "SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION ALL SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '2014-07-19 00:00:00.000000') ) posts"
139
+ )
140
+ expect{union.to_a}.to_not raise_error
141
+ end
142
+ end
129
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_union
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Hempel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description: UNIONs in ActiveRecord! Adds a proper union method to ActiveRecord::Relation.
125
+ description: UNIONs in ActiveRecord! Adds proper union and union_all methods to ActiveRecord::Relation.
126
126
  email:
127
127
  - plasticchicken@gmail.com
128
128
  executables: []
@@ -164,10 +164,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.2.2
167
+ rubygems_version: 2.4.5
168
168
  signing_key:
169
169
  specification_version: 4
170
- summary: UNIONs in ActiveRecord! Adds a proper union method to ActiveRecord::Relation.
170
+ summary: UNIONs in ActiveRecord! Adds proper union and union_all methods to ActiveRecord::Relation.
171
171
  test_files:
172
172
  - spec/spec_helper.rb
173
173
  - spec/support/databases.rb