active_record_union 1.1.1 → 1.2.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/.gitignore +1 -0
- data/.travis.yml +13 -2
- data/README.md +14 -7
- data/Rakefile +57 -4
- data/lib/active_record_union/active_record/relation/union.rb +29 -15
- data/lib/active_record_union/version.rb +1 -1
- data/{Gemfile → rails_4_2.gemfile} +2 -0
- data/rails_5_0.gemfile +6 -0
- data/spec/union_spec.rb +29 -17
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc119e16853585b8595e9c7cf0de7b1282f30411
|
4
|
+
data.tar.gz: eea98a19c016f681636e982ffffb9180e3876e4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efa7fa3f32874d1052bf39f54b4e80e9135980bee70604bf18d12759ba42a5a8ca653427d78ea4ebb9ac6081654a91488ee6758c443d80f7e454061576b7d9f5
|
7
|
+
data.tar.gz: db0f08034881ebe394d656b3b6f997719aaff48dcc979602ca68d8202454182583d50761e725de811bc35e23b5fcf66286947d868bcf1d14dbb103b22ca0ea65
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,7 +2,18 @@ language: ruby
|
|
2
2
|
addons:
|
3
3
|
postgresql: "9.4"
|
4
4
|
rvm:
|
5
|
-
- 2.3.
|
6
|
-
- 2.2.
|
5
|
+
- 2.3.1
|
6
|
+
- 2.2.5
|
7
7
|
- 2.1.8
|
8
8
|
- 2.0.0
|
9
|
+
gemfile:
|
10
|
+
- rails_4_2.gemfile
|
11
|
+
- rails_5_0.gemfile
|
12
|
+
matrix:
|
13
|
+
exclude:
|
14
|
+
# Rails 5 requires Ruby 2.2+:
|
15
|
+
- rvm: 2.1.8
|
16
|
+
gemfile: rails_5_0.gemfile
|
17
|
+
- rvm: 2.0.0
|
18
|
+
gemfile: rails_5_0.gemfile
|
19
|
+
script: bundle exec rspec
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ SELECT "posts".* FROM (
|
|
65
65
|
SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
|
66
66
|
UNION
|
67
67
|
SELECT "posts".* FROM "posts" WHERE (published_at < '2014-07-19 16:04:21.918366')
|
68
|
-
) posts
|
68
|
+
) "posts"
|
69
69
|
```
|
70
70
|
|
71
71
|
Because the `union` method returns another `ActiveRecord::Relation`, we can run further queries on the union.
|
@@ -78,7 +78,7 @@ SELECT "posts".* FROM (
|
|
78
78
|
SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
|
79
79
|
UNION
|
80
80
|
SELECT "posts".* FROM "posts" WHERE (published_at < '2014-07-19 16:06:04.460771')
|
81
|
-
) posts WHERE "posts"."id" IN (6, 7)
|
81
|
+
) "posts" WHERE "posts"."id" IN (6, 7)
|
82
82
|
```
|
83
83
|
|
84
84
|
The `union` method can also accept anything that `where` does.
|
@@ -102,10 +102,10 @@ SELECT "posts".* FROM (
|
|
102
102
|
SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
|
103
103
|
UNION
|
104
104
|
SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 2
|
105
|
-
) posts
|
105
|
+
) "posts"
|
106
106
|
UNION
|
107
107
|
SELECT "posts".* FROM "posts" WHERE (published_at < '2014-07-19 16:12:45.882648')
|
108
|
-
) posts
|
108
|
+
) "posts"
|
109
109
|
```
|
110
110
|
|
111
111
|
### UNION ALL
|
@@ -120,7 +120,7 @@ SELECT "posts".* FROM (
|
|
120
120
|
SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1
|
121
121
|
UNION ALL
|
122
122
|
SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 2
|
123
|
-
) posts
|
123
|
+
) "posts"
|
124
124
|
```
|
125
125
|
|
126
126
|
## Caveats
|
@@ -184,8 +184,11 @@ This is a gem not a Rails pull request because the standard of code quality for
|
|
184
184
|
|
185
185
|
## Changelog
|
186
186
|
|
187
|
+
**1.2.0** - June 26, 2016
|
188
|
+
- Ready for Rails 5.0! Updates provided by [@glebm](https://github.com/glebm).
|
189
|
+
|
187
190
|
**1.1.1** - Mar 19, 2016
|
188
|
-
- Fix broken polymorphic associations and joins due to improper handling of bind values. Fix by [@efradelos](https://github.com/efradelos), reported by [@Machiaweliczny](https://github.com/Machiaweliczny).
|
191
|
+
- Fix broken polymorphic associations and joins due to improper handling of bind values. Fix by [@efradelos](https://github.com/efradelos), reported by [@Machiaweliczny](https://github.com/Machiaweliczny) and [@seandougall](https://github.com/seandougall).
|
189
192
|
- Quote table name aliases properly. Reported by [@odedniv](https://github.com/odedniv).
|
190
193
|
|
191
194
|
**1.1.0** - Mar 29, 2015 - Add UNION ALL support, courtesy of [@pic](https://github.com/pic).
|
@@ -204,7 +207,11 @@ This public domain dedication follows the the CC0 1.0 at https://creativecommons
|
|
204
207
|
|
205
208
|
1. Fork it ( https://github.com/brianhempel/active_record_union/fork )
|
206
209
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
207
|
-
3. Run the tests
|
210
|
+
3. Run the tests:
|
211
|
+
1. Install MySQL and PostgreSQL.
|
212
|
+
2. You may need to create a `test_active_record_union` database on each under the default user.
|
213
|
+
3. Run `rake` to test with all supported Rails versions.
|
214
|
+
4. Run `rake test_rails_4_2` or `rake test_rails_5_0` to test a specific Rails version.
|
208
215
|
4. There is also a `bin/console` command to load up a REPL for playing around
|
209
216
|
5. Commit your changes (`git commit -am 'Add some feature'`)
|
210
217
|
6. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,8 +1,61 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
-
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
task :default => :test_all_gemfiles
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
module TestTasks
|
8
|
+
module_function
|
9
|
+
|
10
|
+
TEST_CMD = 'bundle exec rspec'
|
11
|
+
|
12
|
+
def run_all(envs, cmd = "bundle install && #{TEST_CMD}", success_message)
|
13
|
+
statuses = envs.map { |env| run(env, cmd) }
|
14
|
+
failed = statuses.reject(&:first).map(&:last)
|
15
|
+
if failed.empty?
|
16
|
+
$stderr.puts success_message
|
17
|
+
else
|
18
|
+
$stderr.puts "❌ FAILING (#{failed.size}):\n#{failed.map { |env| to_bash_cmd_with_env(cmd, env) } * "\n"}"
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_one(env, cmd = "bundle install && #{TEST_CMD}")
|
24
|
+
full_cmd = to_bash_cmd_with_env(cmd, env)
|
25
|
+
exec(full_cmd)
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(env, cmd)
|
29
|
+
Bundler.with_clean_env do
|
30
|
+
full_cmd = to_bash_cmd_with_env(cmd, env)
|
31
|
+
$stderr.puts full_cmd
|
32
|
+
isSuccess = system(full_cmd)
|
33
|
+
[isSuccess, env]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def gemfiles
|
38
|
+
Dir.glob('*.gemfile').sort
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_bash_cmd_with_env(cmd, env)
|
42
|
+
"(export #{env.map { |k, v| "#{k}=#{v}" }.join(' ')}; #{cmd})"
|
43
|
+
end
|
8
44
|
end
|
45
|
+
|
46
|
+
desc 'Test all Gemfiles'
|
47
|
+
task :test_all_gemfiles do
|
48
|
+
envs = TestTasks.gemfiles.map { |gemfile| { 'BUNDLE_GEMFILE' => gemfile } }
|
49
|
+
TestTasks.run_all envs, "✓ Tests pass with all #{envs.size} gemfiles"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
TestTasks.gemfiles.each do |gemfile|
|
54
|
+
rails_version_underscored = gemfile[/rails_(.+)\.gemfile/, 1]
|
55
|
+
|
56
|
+
desc "Test Rails #{rails_version_underscored.gsub("_", ".")}"
|
57
|
+
task :"test_rails_#{rails_version_underscored}" do
|
58
|
+
env = { 'BUNDLE_GEMFILE' => gemfile }
|
59
|
+
TestTasks.run_one(env)
|
60
|
+
end
|
61
|
+
end
|
@@ -7,11 +7,11 @@ module ActiveRecord
|
|
7
7
|
union_all: Arel::Nodes::UnionAll
|
8
8
|
}
|
9
9
|
|
10
|
-
def
|
10
|
+
def union(relation_or_where_arg, *args)
|
11
11
|
set_operation(:union, relation_or_where_arg, *args)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def union_all(relation_or_where_arg, *args)
|
15
15
|
set_operation(:union_all, relation_or_where_arg, *args)
|
16
16
|
end
|
17
17
|
|
@@ -19,29 +19,30 @@ module ActiveRecord
|
|
19
19
|
|
20
20
|
def set_operation(operation, relation_or_where_arg, *args)
|
21
21
|
other = if args.size == 0 && Relation === relation_or_where_arg
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
relation_or_where_arg
|
23
|
+
else
|
24
|
+
@klass.where(relation_or_where_arg, *args)
|
25
|
+
end
|
26
26
|
|
27
27
|
verify_relations_for_set_operation!(operation, self, other)
|
28
28
|
|
29
29
|
# Postgres allows ORDER BY in the UNION subqueries if each subquery is surrounded by parenthesis
|
30
30
|
# but SQLite does not allow parens around the subqueries; you will have to explicitly do `relation.reorder(nil)` in SQLite
|
31
|
-
if Arel::Visitors::SQLite === self.visitor
|
31
|
+
if Arel::Visitors::SQLite === self.connection.visitor
|
32
32
|
left, right = self.ast, other.ast
|
33
33
|
else
|
34
34
|
left, right = Arel::Nodes::Grouping.new(self.ast), Arel::Nodes::Grouping.new(other.ast)
|
35
35
|
end
|
36
36
|
|
37
|
-
set
|
38
|
-
from = Arel::Nodes::TableAlias.new(
|
39
|
-
|
40
|
-
@klass.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
set = SET_OPERATION_TO_AREL_CLASS[operation].new(left, right)
|
38
|
+
from = Arel::Nodes::TableAlias.new(set, @klass.arel_table.name)
|
39
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
40
|
+
relation = @klass.unscoped.spawn
|
41
|
+
relation.from_clause = UnionFromClause.new(from, nil, self.bound_attributes + other.bound_attributes)
|
42
|
+
else
|
43
|
+
relation = @klass.unscoped.from(from)
|
44
|
+
relation.bind_values = self.arel.bind_values + self.bind_values + other.arel.bind_values + other.bind_values
|
45
|
+
end
|
45
46
|
relation
|
46
47
|
end
|
47
48
|
|
@@ -62,6 +63,19 @@ module ActiveRecord
|
|
62
63
|
raise ArgumentError.new("Cannot #{operation} relation with eager load.")
|
63
64
|
end
|
64
65
|
end
|
66
|
+
|
67
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
68
|
+
class UnionFromClause < ActiveRecord::Relation::FromClause
|
69
|
+
def initialize(value, name, bound_attributes)
|
70
|
+
super(value, name)
|
71
|
+
@bound_attributes = bound_attributes
|
72
|
+
end
|
73
|
+
|
74
|
+
def binds
|
75
|
+
@bound_attributes
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
65
79
|
end
|
66
80
|
end
|
67
81
|
end
|
data/rails_5_0.gemfile
ADDED
data/spec/union_spec.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ActiveRecord::Relation do
|
4
|
+
TIME = Time.utc(2014, 7, 19, 0, 0, 0)
|
5
|
+
SQL_TIME = ActiveRecord::VERSION::MAJOR >= 5 ? "2014-07-19 00:00:00" : "2014-07-19 00:00:00.000000"
|
6
|
+
|
4
7
|
describe ".union" do
|
5
8
|
it "returns an ActiveRecord::Relation" do
|
6
9
|
expect(User.all.union(User.all)).to be_kind_of(ActiveRecord::Relation)
|
@@ -26,17 +29,25 @@ describe ActiveRecord::Relation do
|
|
26
29
|
end
|
27
30
|
|
28
31
|
it "works" do
|
29
|
-
union = User.new(id: 1).posts.union(Post.where("created_at > ?",
|
32
|
+
union = User.new(id: 1).posts.union(Post.where("created_at > ?", TIME))
|
30
33
|
|
31
34
|
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 > '
|
35
|
+
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '#{SQL_TIME}') ) \"posts\""
|
33
36
|
)
|
34
37
|
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 > '
|
38
|
+
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ? UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '#{SQL_TIME}') ) \"posts\""
|
36
39
|
)
|
37
40
|
expect{union.to_a}.to_not raise_error
|
38
41
|
end
|
39
42
|
|
43
|
+
def bind_values_from_relation(relation)
|
44
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
45
|
+
relation.bound_attributes.map { |a| a.value_for_database }
|
46
|
+
else
|
47
|
+
(relation.arel.bind_values + relation.bind_values).map { |_column, value| value }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
40
51
|
it "binds values properly" do
|
41
52
|
user1 = User.new(id: 1)
|
42
53
|
user2 = User.new(id: 2)
|
@@ -46,7 +57,7 @@ describe ActiveRecord::Relation do
|
|
46
57
|
|
47
58
|
# Inside ActiveRecord the bind value list is
|
48
59
|
# (union.arel.bind_values + union.bind_values)
|
49
|
-
bind_values =
|
60
|
+
bind_values = bind_values_from_relation union
|
50
61
|
|
51
62
|
expect(bind_values).to eq([1, 2, 3])
|
52
63
|
end
|
@@ -54,7 +65,7 @@ describe ActiveRecord::Relation do
|
|
54
65
|
it "binds values properly on joins" do
|
55
66
|
union = User.joins(:drafts).union(User.where(id: 11))
|
56
67
|
|
57
|
-
bind_values =
|
68
|
+
bind_values = bind_values_from_relation union
|
58
69
|
expect(bind_values).to eq([true, 11])
|
59
70
|
|
60
71
|
|
@@ -66,31 +77,32 @@ describe ActiveRecord::Relation do
|
|
66
77
|
|
67
78
|
it "doesn't repeat default scopes" do
|
68
79
|
expect(Time).to receive(:now) { Time.utc(2014, 7, 24, 0, 0, 0) }
|
80
|
+
sql_now = "2014-07-24 00:00:00#{".000000" if ActiveRecord::VERSION::MAJOR < 5}"
|
69
81
|
|
70
82
|
class PublishedPost < ActiveRecord::Base
|
71
83
|
self.table_name = "posts"
|
72
84
|
default_scope { where("published_at < ?", Time.now) }
|
73
85
|
end
|
74
86
|
|
75
|
-
union = PublishedPost.where("created_at > ?",
|
87
|
+
union = PublishedPost.where("created_at > ?", TIME).union(User.new(id: 1).posts)
|
76
88
|
|
77
89
|
expect(union.to_sql.squish).to eq(
|
78
|
-
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE (published_at < '
|
90
|
+
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE (published_at < '#{sql_now}') AND (created_at > '#{SQL_TIME}') UNION SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 ) \"posts\""
|
79
91
|
)
|
80
92
|
expect{union.to_a}.to_not raise_error
|
81
93
|
end
|
82
94
|
|
83
95
|
context "with ORDER BY in subselects" do
|
84
|
-
|
96
|
+
let :union do
|
85
97
|
User.new(id: 1).posts.order(:created_at).union(
|
86
|
-
Post.where("created_at > ?",
|
98
|
+
Post.where("created_at > ?", TIME).order(:created_at)
|
87
99
|
).order(:created_at)
|
88
100
|
end
|
89
101
|
|
90
102
|
context "in SQLite" do
|
91
103
|
it "lets ORDER BY in query subselects throw a syntax error" do
|
92
104
|
expect(union.to_sql.squish).to eq(
|
93
|
-
"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 > '
|
105
|
+
"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 > '#{SQL_TIME}') ORDER BY \"posts\".\"created_at\" ASC ) \"posts\" ORDER BY \"posts\".\"created_at\" ASC"
|
94
106
|
)
|
95
107
|
expect{union.to_a}.to raise_error(ActiveRecord::StatementInvalid)
|
96
108
|
end
|
@@ -100,7 +112,7 @@ describe ActiveRecord::Relation do
|
|
100
112
|
it "wraps query subselects in parentheses to allow ORDER BY clauses" do
|
101
113
|
Databases.with_postgres do
|
102
114
|
expect(union.to_sql.squish).to eq(
|
103
|
-
"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 > '
|
115
|
+
"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 > '#{SQL_TIME}') ORDER BY \"posts\".\"created_at\" ASC) ) \"posts\" ORDER BY \"posts\".\"created_at\" ASC"
|
104
116
|
)
|
105
117
|
expect{union.to_a}.to_not raise_error
|
106
118
|
end
|
@@ -111,7 +123,7 @@ describe ActiveRecord::Relation do
|
|
111
123
|
it "wraps query subselects in parentheses to allow ORDER BY clauses" do
|
112
124
|
Databases.with_mysql do
|
113
125
|
expect(union.to_sql.squish).to eq(
|
114
|
-
"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 > '
|
126
|
+
"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 > '#{SQL_TIME}') ORDER BY `posts`.`created_at` ASC) ) `posts` ORDER BY `posts`.`created_at` ASC"
|
115
127
|
)
|
116
128
|
expect{union.to_a}.to_not raise_error
|
117
129
|
end
|
@@ -130,10 +142,10 @@ describe ActiveRecord::Relation do
|
|
130
142
|
end
|
131
143
|
|
132
144
|
it "multiple arguments" do
|
133
|
-
union = User.new(id: 1).posts.union("created_at > ?",
|
145
|
+
union = User.new(id: 1).posts.union("created_at > ?", TIME)
|
134
146
|
|
135
147
|
expect(union.to_sql.squish).to eq(
|
136
|
-
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '
|
148
|
+
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '#{SQL_TIME}') ) \"posts\""
|
137
149
|
)
|
138
150
|
expect{union.to_a}.to_not raise_error
|
139
151
|
end
|
@@ -151,10 +163,10 @@ describe ActiveRecord::Relation do
|
|
151
163
|
|
152
164
|
describe ".union_all" do
|
153
165
|
it "works" do
|
154
|
-
union = User.new(id: 1).posts.union_all(Post.where("created_at > ?",
|
166
|
+
union = User.new(id: 1).posts.union_all(Post.where("created_at > ?", TIME))
|
155
167
|
|
156
168
|
expect(union.to_sql.squish).to eq(
|
157
|
-
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION ALL SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '
|
169
|
+
"SELECT \"posts\".* FROM ( SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = 1 UNION ALL SELECT \"posts\".* FROM \"posts\" WHERE (created_at > '#{SQL_TIME}') ) \"posts\""
|
158
170
|
)
|
159
171
|
expect{union.to_a}.to_not raise_error
|
160
172
|
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.
|
4
|
+
version: 1.2.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: 2016-
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -131,7 +131,6 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
133
|
- ".travis.yml"
|
134
|
-
- Gemfile
|
135
134
|
- LICENSE.txt
|
136
135
|
- README.md
|
137
136
|
- Rakefile
|
@@ -140,6 +139,8 @@ files:
|
|
140
139
|
- lib/active_record_union.rb
|
141
140
|
- lib/active_record_union/active_record/relation/union.rb
|
142
141
|
- lib/active_record_union/version.rb
|
142
|
+
- rails_4_2.gemfile
|
143
|
+
- rails_5_0.gemfile
|
143
144
|
- spec/spec_helper.rb
|
144
145
|
- spec/support/databases.rb
|
145
146
|
- spec/support/models.rb
|