rom-sql 1.0.1 → 1.0.2
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 +10 -0
- data/Gemfile +1 -0
- data/lib/rom/sql/attribute.rb +1 -1
- data/lib/rom/sql/projection_dsl.rb +6 -0
- data/lib/rom/sql/version.rb +1 -1
- data/rom-sql.gemspec +1 -1
- data/spec/integration/association/many_to_many/custom_fks_spec.rb +9 -13
- data/spec/integration/association/many_to_many/from_view_spec.rb +9 -8
- data/spec/integration/association/many_to_many_spec.rb +103 -102
- data/spec/integration/association/many_to_one/custom_fks_spec.rb +6 -7
- data/spec/integration/association/many_to_one/from_view_spec.rb +8 -4
- data/spec/integration/association/many_to_one_spec.rb +61 -54
- data/spec/integration/association/one_to_many/custom_fks_spec.rb +7 -6
- data/spec/integration/association/one_to_many/from_view_spec.rb +7 -10
- data/spec/integration/association/one_to_many/self_ref_spec.rb +6 -6
- data/spec/integration/association/one_to_many_spec.rb +0 -3
- data/spec/integration/association/one_to_one_spec.rb +17 -11
- data/spec/integration/association/one_to_one_through_spec.rb +3 -5
- data/spec/integration/commands/create_spec.rb +33 -22
- data/spec/integration/commands/update_spec.rb +3 -3
- data/spec/integration/commands/upsert_spec.rb +1 -1
- data/spec/integration/gateway_spec.rb +12 -8
- data/spec/integration/migration_spec.rb +4 -3
- data/spec/integration/plugins/associates/many_to_many_spec.rb +2 -2
- data/spec/integration/plugins/associates_spec.rb +1 -1
- data/spec/integration/relation_schema_spec.rb +4 -5
- data/spec/integration/schema/call_spec.rb +1 -1
- data/spec/integration/schema/inferrer/mysql_spec.rb +22 -23
- data/spec/integration/schema/inferrer/postgres_spec.rb +83 -82
- data/spec/integration/schema/inferrer/sqlite_spec.rb +18 -19
- data/spec/integration/schema/inferrer_spec.rb +54 -33
- data/spec/integration/schema/prefix_spec.rb +9 -11
- data/spec/integration/schema/qualified_spec.rb +9 -11
- data/spec/integration/schema/rename_spec.rb +13 -15
- data/spec/integration/schema/view_spec.rb +2 -2
- data/spec/integration/sequel_api_spec.rb +1 -1
- data/spec/integration/setup_spec.rb +5 -5
- data/spec/integration/support/active_support_notifications_spec.rb +2 -2
- data/spec/integration/support/rails_log_subscriber_spec.rb +2 -2
- data/spec/shared/accounts.rb +44 -0
- data/spec/shared/database_setup.rb +42 -81
- data/spec/shared/notes.rb +21 -0
- data/spec/shared/posts.rb +32 -0
- data/spec/shared/puppies.rb +13 -0
- data/spec/shared/relations.rb +1 -1
- data/spec/shared/users.rb +29 -0
- data/spec/shared/users_and_tasks.rb +32 -18
- data/spec/spec_helper.rb +18 -30
- data/spec/support/env_helper.rb +25 -0
- data/spec/support/oracle/create_users.sql +7 -0
- data/spec/support/oracle/set_sys_passwords.sql +2 -0
- data/spec/unit/plugin/pagination_spec.rb +2 -2
- data/spec/unit/plugin/timestamp_spec.rb +1 -1
- data/spec/unit/projection_dsl_spec.rb +8 -0
- data/spec/unit/relation/group_spec.rb +5 -3
- data/spec/unit/relation/max_spec.rb +1 -1
- data/spec/unit/relation/select_spec.rb +7 -0
- metadata +33 -5
- data/spec/shared/users_and_accounts.rb +0 -10
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ROM::SQL::Association::ManyToOne, '#call' do
|
4
|
+
include_context 'database setup'
|
5
|
+
|
6
|
+
before do
|
7
|
+
inferrable_relations.concat %i(destinations flights)
|
8
|
+
end
|
9
|
+
|
4
10
|
let(:assoc_inter) { relations[:flights].associations[:inter_destination] }
|
5
11
|
let(:assoc_final) { relations[:flights].associations[:final_destination] }
|
6
12
|
|
7
|
-
include_context 'database setup'
|
8
|
-
|
9
13
|
with_adapters do
|
10
14
|
before do
|
11
15
|
conn.create_table(:destinations) do
|
@@ -59,7 +63,7 @@ RSpec.describe ROM::SQL::Association::ManyToOne, '#call' do
|
|
59
63
|
expect(relation.schema.map(&:to_sym)).
|
60
64
|
to eql(%i(destinations__id destinations__name destinations__intermediate flights__id___flight_id))
|
61
65
|
|
62
|
-
expect(relation.first).to eql(id: 2, intermediate:
|
66
|
+
expect(relation.first).to eql(id: 2, intermediate: db_true, name: 'Intermediate', flight_id: 1)
|
63
67
|
expect(relation.count).to be(1)
|
64
68
|
|
65
69
|
relation = assoc_final.call(relations)
|
@@ -67,7 +71,7 @@ RSpec.describe ROM::SQL::Association::ManyToOne, '#call' do
|
|
67
71
|
expect(relation.schema.map(&:to_sym)).
|
68
72
|
to eql(%i(destinations__id destinations__name destinations__intermediate flights__id___flight_id))
|
69
73
|
|
70
|
-
expect(relation.first).to eql(id: 1, intermediate:
|
74
|
+
expect(relation.first).to eql(id: 1, intermediate: db_false, name: 'Final', flight_id: 2)
|
71
75
|
expect(relation.count).to be(1)
|
72
76
|
end
|
73
77
|
end
|
@@ -1,86 +1,93 @@
|
|
1
1
|
RSpec.describe ROM::SQL::Association::ManyToOne, helpers: true do
|
2
|
-
subject(:assoc) {
|
3
|
-
ROM::SQL::Association::ManyToOne.new(:tasks, :users)
|
4
|
-
}
|
5
|
-
|
6
|
-
include_context 'users and tasks'
|
7
|
-
|
8
2
|
let(:users) { container.relations[:users] }
|
9
3
|
let(:tasks) { container.relations[:tasks] }
|
10
|
-
let(:articles) { container.relations[:articles] }
|
11
4
|
|
12
5
|
with_adapters do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
context 'common name conventions' do
|
7
|
+
include_context 'users and tasks'
|
8
|
+
include_context 'accounts'
|
9
|
+
|
10
|
+
subject(:assoc) {
|
11
|
+
ROM::SQL::Association::ManyToOne.new(:tasks, :users)
|
12
|
+
}
|
13
|
+
|
14
|
+
before do
|
15
|
+
conf.relation(:tasks) do
|
16
|
+
schema do
|
17
|
+
attribute :id, ROM::SQL::Types::Serial
|
18
|
+
attribute :user_id, ROM::SQL::Types::ForeignKey(:users)
|
19
|
+
attribute :title, ROM::SQL::Types::String
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
describe '#result' do
|
25
|
+
specify { expect(ROM::SQL::Association::ManyToOne.result).to be(:one) }
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
describe '#name' do
|
29
|
+
it 'uses target by default' do
|
30
|
+
expect(assoc.name).to be(:users)
|
31
|
+
end
|
30
32
|
end
|
31
|
-
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
describe '#target' do
|
35
|
+
it 'builds full relation name' do
|
36
|
+
assoc = ROM::SQL::Association::ManyToOne.new(:users, :tasks, relation: :foo)
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
expect(assoc.name).to be(:tasks)
|
39
|
+
expect(assoc.target).to eql(ROM::SQL::Association::Name[:foo, :tasks])
|
40
|
+
end
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
describe '#call' do
|
44
|
+
it 'prepares joined relations' do
|
45
|
+
relation = assoc.call(container.relations)
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
expect(relation.schema.map(&:to_sym))
|
48
|
+
.to eql(%i[users__id users__name tasks__id___task_id])
|
48
49
|
|
49
|
-
|
50
|
+
expect(relation.where(user_id: 1).one).to eql(id: 1, task_id: 2, name: 'Jane')
|
50
51
|
|
51
|
-
|
52
|
+
expect(relation.where(user_id: 2).one).to eql(id: 2, task_id: 1, name: 'Joe')
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
expect(relation.to_a).
|
55
|
+
to eql([{ id: 2, task_id: 1, name: 'Joe' },
|
56
|
+
{ id: 1, task_id: 2, name: 'Jane' }])
|
57
|
+
end
|
57
58
|
end
|
58
|
-
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
describe ROM::Plugins::Relation::SQL::AutoCombine, '#for_combine' do
|
61
|
+
it 'preloads relation based on association' do
|
62
|
+
relation = users.for_combine(assoc).call(tasks.call)
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
64
|
+
expect(relation.to_a).
|
65
|
+
to eql([{ id: 2, task_id: 1, name: 'Joe' },
|
66
|
+
{ id: 1, task_id: 2, name: 'Jane' }])
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
69
|
+
it 'maintains original relation' do
|
70
|
+
users.accounts.insert(user_id: 2, number: 'a1', balance: 0)
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
relation = users.
|
73
|
+
join(:accounts, user_id: :id).
|
74
|
+
select_append(users.accounts[:number].as(:account_num)).
|
75
|
+
order(:account_num).
|
76
|
+
for_combine(assoc).call(tasks.call)
|
77
77
|
|
78
|
-
|
78
|
+
expect(relation.to_a).
|
79
|
+
to eql([{ id: 2, task_id: 1, name: 'Joe', account_num: 'a1' },
|
80
|
+
{ id: 1, task_id: 2, name: 'Jane', account_num: '42' }])
|
81
|
+
end
|
79
82
|
end
|
80
83
|
end
|
81
84
|
|
82
85
|
context 'arbitrary name conventions' do
|
86
|
+
include_context 'users'
|
87
|
+
include_context 'posts'
|
88
|
+
|
83
89
|
let(:articles_name) { ROM::Relation::Name[:articles, :posts] }
|
90
|
+
let(:articles) { container.relations[:articles] }
|
84
91
|
|
85
92
|
subject(:assoc) do
|
86
93
|
ROM::SQL::Association::ManyToOne.new(articles_name, :users)
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
4
|
+
include_context 'users'
|
5
|
+
|
6
|
+
before do
|
7
|
+
inferrable_relations.concat %i(puzzles)
|
8
|
+
end
|
9
|
+
|
4
10
|
subject(:assoc) do
|
5
11
|
relations[:users].associations[:solved_puzzles]
|
6
12
|
end
|
7
13
|
|
8
|
-
include_context 'database setup'
|
9
|
-
|
10
14
|
with_adapters do
|
11
15
|
before do
|
12
16
|
conn.create_table(:puzzles) do
|
@@ -25,9 +29,6 @@ RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
joe_id = relations[:users].insert(name: 'Joe')
|
29
|
-
jane_id = relations[:users].insert(name: 'Jane')
|
30
|
-
|
31
32
|
relations[:puzzles].insert(author_id: joe_id, text: 'P1')
|
32
33
|
relations[:puzzles].insert(author_id: joe_id, solver_id: jane_id, text: 'P2')
|
33
34
|
end
|
@@ -42,7 +43,7 @@ RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
|
42
43
|
expect(relation.schema.map(&:to_sym)).
|
43
44
|
to eql(%i[puzzles__id puzzles__author_id puzzles__solver_id puzzles__text])
|
44
45
|
|
45
|
-
expect(relation.first).to eql(id: 2, author_id:
|
46
|
+
expect(relation.first).to eql(id: 2, author_id: 2, solver_id: 1, text: 'P2')
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
4
|
+
include_context 'users'
|
5
|
+
|
6
|
+
before do
|
7
|
+
inferrable_relations.concat %i(puzzles)
|
8
|
+
end
|
9
|
+
|
4
10
|
subject(:assoc) do
|
5
11
|
relations[:users].associations[:solved_puzzles]
|
6
12
|
end
|
7
13
|
|
8
|
-
include_context 'database setup'
|
9
|
-
|
10
14
|
with_adapters do
|
11
15
|
before do
|
12
16
|
conn.create_table(:puzzles) do
|
@@ -33,17 +37,10 @@ RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
|
-
joe_id = relations[:users].insert(name: 'Joe')
|
37
|
-
jane_id = relations[:users].insert(name: 'Jane')
|
38
|
-
|
39
40
|
relations[:puzzles].insert(user_id: joe_id, text: 'P1')
|
40
41
|
relations[:puzzles].insert(user_id: joe_id, solved: true, text: 'P2')
|
41
42
|
end
|
42
43
|
|
43
|
-
after do
|
44
|
-
conn.drop_table(:puzzles)
|
45
|
-
end
|
46
|
-
|
47
44
|
it 'prepares joined relations using custom view' do
|
48
45
|
relation = assoc.call(relations)
|
49
46
|
|
@@ -51,7 +48,7 @@ RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
|
51
48
|
to eql(%i[puzzles__id puzzles__user_id puzzles__text puzzles__solved])
|
52
49
|
|
53
50
|
expect(relation.count).to be(1)
|
54
|
-
expect(relation.first).to eql(id: 2, user_id:
|
51
|
+
expect(relation.first).to eql(id: 2, user_id: 2, solved: db_true, text: 'P2')
|
55
52
|
end
|
56
53
|
end
|
57
54
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
4
|
+
include_context 'database setup'
|
5
|
+
|
6
|
+
before do
|
7
|
+
inferrable_relations.concat %i(categories)
|
8
|
+
end
|
9
|
+
|
4
10
|
subject(:assoc) do
|
5
11
|
relations[:categories].associations[:children]
|
6
12
|
end
|
7
13
|
|
8
|
-
include_context 'database setup'
|
9
|
-
|
10
14
|
with_adapters do
|
11
15
|
before do
|
12
16
|
conn.create_table(:categories) do
|
@@ -31,10 +35,6 @@ RSpec.describe ROM::SQL::Association::OneToMany, '#call' do
|
|
31
35
|
c3_id = relations[:categories].insert(name: 'C5', parent_id: p1_id)
|
32
36
|
end
|
33
37
|
|
34
|
-
after do
|
35
|
-
conn.drop_table(:categories)
|
36
|
-
end
|
37
|
-
|
38
38
|
it 'prepares joined relations using custom FK for a self-ref association' do
|
39
39
|
relation = assoc.call(relations)
|
40
40
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
RSpec.describe ROM::SQL::Association::OneToOne do
|
2
|
+
include_context 'users'
|
3
|
+
include_context 'accounts'
|
4
|
+
|
2
5
|
subject(:assoc) {
|
3
6
|
ROM::SQL::Association::OneToOne.new(:users, :accounts)
|
4
7
|
}
|
5
8
|
|
6
|
-
include_context 'users and accounts'
|
7
|
-
|
8
|
-
let(:users) { container.relations[:users] }
|
9
|
-
let(:accounts) { container.relations[:accounts] }
|
10
|
-
|
11
9
|
with_adapters do
|
12
10
|
before do
|
11
|
+
conn[:accounts].insert user_id: 1, number: '43', balance: -273.15.to_d
|
12
|
+
|
13
13
|
conf.relation(:accounts) do
|
14
14
|
schema do
|
15
15
|
attribute :id, ROM::SQL::Types::Serial
|
@@ -33,10 +33,13 @@ RSpec.describe ROM::SQL::Association::OneToOne do
|
|
33
33
|
# TODO: this if caluse should be removed when (and if) https://github.com/xerial/sqlite-jdbc/issues/112
|
34
34
|
# will be resolved. See https://github.com/rom-rb/rom-sql/issues/49 for details
|
35
35
|
if jruby? && sqlite?(example)
|
36
|
-
expect(relation.to_a).
|
36
|
+
expect(relation.to_a).
|
37
|
+
to eql([{ id: 1, user_id: 1, number: '42', balance: 10_000 },
|
38
|
+
{ id: 2, user_id: 1, number: '43', balance: -273.15 }])
|
37
39
|
else
|
38
|
-
|
39
|
-
|
40
|
+
expect(relation.to_a).
|
41
|
+
to eql([{ id: 1, user_id: 1, number: '42', balance: 10_000.to_d },
|
42
|
+
{ id: 2, user_id: 1, number: '43', balance: -273.15.to_d }])
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
@@ -48,10 +51,13 @@ RSpec.describe ROM::SQL::Association::OneToOne do
|
|
48
51
|
# TODO: this if caluse should be removed when (and if) https://github.com/xerial/sqlite-jdbc/issues/112
|
49
52
|
# will be resolved. See https://github.com/rom-rb/rom-sql/issues/49 for details
|
50
53
|
if jruby? && sqlite?(example)
|
51
|
-
expect(relation.to_a).
|
54
|
+
expect(relation.to_a).
|
55
|
+
to eql([{ id: 1, user_id: 1, number: '42', balance: 10_000 },
|
56
|
+
{ id: 2, user_id: 1, number: '43', balance: -273.15 }])
|
52
57
|
else
|
53
|
-
|
54
|
-
|
58
|
+
expect(relation.to_a).
|
59
|
+
to eql([{ id: 1, user_id: 1, number: '42', balance: 10_000.to_d },
|
60
|
+
{ id: 2, user_id: 1, number: '43', balance: -273.15.to_d }])
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
RSpec.describe ROM::SQL::Association::OneToOneThrough do
|
2
|
+
include_context 'users'
|
3
|
+
include_context 'accounts'
|
4
|
+
|
2
5
|
subject(:assoc) {
|
3
6
|
ROM::SQL::Association::OneToOneThrough.new(:users, :cards, through: :accounts)
|
4
7
|
}
|
5
8
|
|
6
|
-
include_context 'users and accounts'
|
7
|
-
|
8
|
-
let(:users) { container.relations[:users] }
|
9
|
-
let(:cards) { container.relations[:cards] }
|
10
|
-
|
11
9
|
with_adapters do
|
12
10
|
before do
|
13
11
|
conf.relation(:accounts) do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'dry-struct'
|
2
2
|
|
3
|
-
RSpec.describe 'Commands / Create', :postgres do
|
3
|
+
RSpec.describe 'Commands / Create', :postgres, seeds: false do
|
4
4
|
include_context 'relations'
|
5
5
|
|
6
6
|
let(:users) { commands[:users] }
|
@@ -19,10 +19,6 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
19
19
|
|
20
20
|
conn.add_index :users, :name, unique: true
|
21
21
|
|
22
|
-
conf.relation(:puppies) do
|
23
|
-
schema(infer: true)
|
24
|
-
end
|
25
|
-
|
26
22
|
conf.commands(:users) do
|
27
23
|
define(:create) do
|
28
24
|
input Test::Params
|
@@ -38,10 +34,6 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
38
34
|
conf.commands(:tasks) do
|
39
35
|
define(:create)
|
40
36
|
end
|
41
|
-
|
42
|
-
conf.commands(:puppies) do
|
43
|
-
define(:create)
|
44
|
-
end
|
45
37
|
end
|
46
38
|
|
47
39
|
with_adapters do
|
@@ -51,7 +43,7 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
51
43
|
users.create.call(name: 'Jane')
|
52
44
|
}
|
53
45
|
|
54
|
-
expect(result.value).to
|
46
|
+
expect(result.value).to eql(id: 1, name: 'Jane')
|
55
47
|
end
|
56
48
|
|
57
49
|
it 'creates multiple records if nothing was raised' do
|
@@ -71,7 +63,7 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
71
63
|
}
|
72
64
|
}
|
73
65
|
|
74
|
-
expect(result.value).to
|
66
|
+
expect(result.value).to eql(id: 1, name: 'Jane')
|
75
67
|
end
|
76
68
|
|
77
69
|
it 'creates nothing if command error was raised' do
|
@@ -182,12 +174,30 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
182
174
|
}.to raise_error(ROM::SQL::NotNullConstraintError)
|
183
175
|
end
|
184
176
|
|
185
|
-
|
186
|
-
|
177
|
+
# Because Oracle doesn't have boolean in SQL
|
178
|
+
if !metadata[:oracle]
|
179
|
+
context 'with puppies' do
|
180
|
+
include_context 'puppies'
|
187
181
|
|
188
|
-
|
189
|
-
|
190
|
-
|
182
|
+
before do
|
183
|
+
conf.relation(:puppies) do
|
184
|
+
schema(infer: true)
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
conf.commands(:puppies) do
|
189
|
+
define(:create)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
it 're-raises not-null constraint violation error with nil boolean' do
|
194
|
+
puppies = commands[:puppies]
|
195
|
+
|
196
|
+
expect {
|
197
|
+
puppies.try { puppies.create.call(name: 'Charlie', cute: nil) }
|
198
|
+
}.to raise_error(ROM::SQL::NotNullConstraintError)
|
199
|
+
end
|
200
|
+
end
|
191
201
|
end
|
192
202
|
|
193
203
|
it 're-raises uniqueness constraint violation error' do
|
@@ -239,7 +249,11 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
239
249
|
|
240
250
|
context 'with a composite pk' do
|
241
251
|
before do
|
242
|
-
|
252
|
+
inferrable_relations.concat %i(user_group)
|
253
|
+
end
|
254
|
+
|
255
|
+
before do
|
256
|
+
conn.create_table(:user_group) do
|
243
257
|
primary_key [:user_id, :group_id]
|
244
258
|
column :user_id, Integer, null: false
|
245
259
|
column :group_id, Integer, null: false
|
@@ -254,16 +268,13 @@ RSpec.describe 'Commands / Create', :postgres do
|
|
254
268
|
end
|
255
269
|
end
|
256
270
|
|
257
|
-
after do
|
258
|
-
conn.drop_table(:user_group)
|
259
|
-
end
|
260
|
-
|
261
271
|
# with a composite pk sequel returns 0 when inserting for MySQL
|
262
272
|
if !metadata[:mysql]
|
263
|
-
it 'materializes the result' do
|
273
|
+
it 'materializes the result' do |ex|
|
264
274
|
command = container.commands[:user_group][:create]
|
265
275
|
result = command.call(user_id: 1, group_id: 2)
|
266
276
|
|
277
|
+
pending "if sequel could use Oracle's RETURNING statement, that would be possible" if oracle?(ex)
|
267
278
|
expect(result).to eql(user_id: 1, group_id: 2)
|
268
279
|
end
|
269
280
|
end
|