rom-sql 1.3.5 → 2.0.0.beta1

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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -7
  3. data/Gemfile +7 -5
  4. data/lib/rom/plugins/relation/sql/auto_restrictions.rb +11 -17
  5. data/lib/rom/sql.rb +3 -2
  6. data/lib/rom/sql/associations.rb +5 -0
  7. data/lib/rom/sql/associations/core.rb +20 -0
  8. data/lib/rom/sql/associations/many_to_many.rb +83 -0
  9. data/lib/rom/sql/associations/many_to_one.rb +55 -0
  10. data/lib/rom/sql/associations/one_to_many.rb +31 -0
  11. data/lib/rom/sql/{association → associations}/one_to_one.rb +3 -2
  12. data/lib/rom/sql/{association → associations}/one_to_one_through.rb +3 -2
  13. data/lib/rom/sql/associations/self_ref.rb +39 -0
  14. data/lib/rom/sql/attribute.rb +44 -54
  15. data/lib/rom/sql/errors.rb +2 -0
  16. data/lib/rom/sql/extensions/mysql.rb +1 -1
  17. data/lib/rom/sql/extensions/mysql/attributes_inferrer.rb +10 -0
  18. data/lib/rom/sql/extensions/postgres.rb +1 -1
  19. data/lib/rom/sql/extensions/postgres/{inferrer.rb → attributes_inferrer.rb} +4 -4
  20. data/lib/rom/sql/extensions/postgres/types.rb +9 -19
  21. data/lib/rom/sql/extensions/sqlite.rb +1 -1
  22. data/lib/rom/sql/extensions/sqlite/{inferrer.rb → attributes_inferrer.rb} +2 -2
  23. data/lib/rom/sql/gateway.rb +29 -30
  24. data/lib/rom/sql/index.rb +13 -0
  25. data/lib/rom/sql/migration.rb +10 -0
  26. data/lib/rom/sql/migration/inline_runner.rb +86 -0
  27. data/lib/rom/sql/migration/migrator.rb +17 -0
  28. data/lib/rom/sql/migration/schema_diff.rb +177 -0
  29. data/lib/rom/sql/plugin/associates.rb +11 -45
  30. data/lib/rom/sql/plugin/pagination.rb +4 -4
  31. data/lib/rom/sql/relation.rb +22 -42
  32. data/lib/rom/sql/relation/reading.rb +3 -3
  33. data/lib/rom/sql/schema.rb +14 -21
  34. data/lib/rom/sql/schema/associations_dsl.rb +7 -6
  35. data/lib/rom/sql/schema/attributes_inferrer.rb +164 -0
  36. data/lib/rom/sql/schema/inferrer.rb +40 -141
  37. data/lib/rom/sql/type_extensions.rb +44 -0
  38. data/lib/rom/sql/version.rb +1 -1
  39. data/lib/rom/sql/wrap.rb +25 -0
  40. data/rom-sql.gemspec +2 -2
  41. data/spec/integration/{association → associations}/many_to_many/custom_fks_spec.rb +4 -2
  42. data/spec/integration/{association → associations}/many_to_many/from_view_spec.rb +2 -2
  43. data/spec/integration/{association → associations}/many_to_many_spec.rb +25 -30
  44. data/spec/integration/{association → associations}/many_to_one/custom_fks_spec.rb +5 -3
  45. data/spec/integration/{association → associations}/many_to_one/from_view_spec.rb +3 -3
  46. data/spec/integration/{association → associations}/many_to_one/self_ref_spec.rb +2 -2
  47. data/spec/integration/{association → associations}/many_to_one_spec.rb +20 -38
  48. data/spec/integration/{association → associations}/one_to_many/custom_fks_spec.rb +4 -2
  49. data/spec/integration/{association → associations}/one_to_many/from_view_spec.rb +2 -2
  50. data/spec/integration/{association → associations}/one_to_many/self_ref_spec.rb +2 -2
  51. data/spec/integration/{association → associations}/one_to_many_spec.rb +24 -11
  52. data/spec/integration/{association → associations}/one_to_one_spec.rb +13 -9
  53. data/spec/integration/{association → associations}/one_to_one_through_spec.rb +15 -11
  54. data/spec/integration/auto_migrations/errors_spec.rb +31 -0
  55. data/spec/integration/auto_migrations/indexes_spec.rb +109 -0
  56. data/spec/integration/auto_migrations/managing_columns_spec.rb +156 -0
  57. data/spec/integration/auto_migrations/postgres/column_types_spec.rb +63 -0
  58. data/spec/integration/commands/create_spec.rb +2 -4
  59. data/spec/integration/commands/delete_spec.rb +2 -2
  60. data/spec/integration/commands/update_spec.rb +2 -0
  61. data/spec/integration/graph_spec.rb +9 -3
  62. data/spec/integration/plugins/associates_spec.rb +16 -55
  63. data/spec/integration/plugins/auto_restrictions_spec.rb +0 -11
  64. data/spec/integration/relation_schema_spec.rb +49 -25
  65. data/spec/integration/schema/inferrer/postgres_spec.rb +1 -1
  66. data/spec/integration/schema/inferrer_spec.rb +7 -18
  67. data/spec/integration/setup_spec.rb +4 -0
  68. data/spec/integration/{plugins/auto_wrap_spec.rb → wrap_spec.rb} +13 -36
  69. data/spec/shared/accounts.rb +4 -0
  70. data/spec/shared/database_setup.rb +2 -1
  71. data/spec/shared/notes.rb +2 -0
  72. data/spec/shared/posts.rb +2 -0
  73. data/spec/shared/puppies.rb +2 -0
  74. data/spec/shared/relations.rb +2 -2
  75. data/spec/shared/users.rb +2 -0
  76. data/spec/shared/users_and_tasks.rb +4 -0
  77. data/spec/spec_helper.rb +3 -6
  78. data/spec/support/helpers.rb +11 -8
  79. data/spec/support/test_configuration.rb +16 -0
  80. data/spec/unit/plugin/associates_spec.rb +5 -10
  81. data/spec/unit/plugin/pagination_spec.rb +9 -9
  82. data/spec/unit/plugin/timestamp_spec.rb +9 -9
  83. data/spec/unit/relation/dataset_spec.rb +7 -5
  84. data/spec/unit/relation/inner_join_spec.rb +2 -15
  85. data/spec/unit/relation/primary_key_spec.rb +1 -1
  86. data/spec/unit/schema_spec.rb +6 -4
  87. metadata +65 -70
  88. data/lib/rom/plugins/relation/sql/auto_combine.rb +0 -71
  89. data/lib/rom/plugins/relation/sql/auto_wrap.rb +0 -62
  90. data/lib/rom/sql/association.rb +0 -103
  91. data/lib/rom/sql/association/many_to_many.rb +0 -119
  92. data/lib/rom/sql/association/many_to_one.rb +0 -73
  93. data/lib/rom/sql/association/name.rb +0 -78
  94. data/lib/rom/sql/association/one_to_many.rb +0 -60
  95. data/lib/rom/sql/extensions/mysql/inferrer.rb +0 -10
  96. data/lib/rom/sql/qualified_attribute.rb +0 -53
  97. data/lib/rom/sql/schema/dsl.rb +0 -75
  98. data/spec/unit/association/many_to_many_spec.rb +0 -89
  99. data/spec/unit/association/many_to_one_spec.rb +0 -81
  100. data/spec/unit/association/name_spec.rb +0 -68
  101. data/spec/unit/association/one_to_many_spec.rb +0 -82
  102. data/spec/unit/association/one_to_one_spec.rb +0 -83
  103. data/spec/unit/association/one_to_one_through_spec.rb +0 -69
@@ -39,16 +39,5 @@ RSpec.describe 'Plugins / :auto_restrictions', seeds: true do
39
39
 
40
40
  include_context 'auto-generated restriction view'
41
41
  end
42
-
43
- it 'raises error when enabled w/o a schema' do
44
- expect {
45
- conf.relation(:tasks) do
46
- use :auto_restrictions
47
- end
48
- }.to raise_error(
49
- ROM::Plugins::Relation::SQL::AutoRestrictions::EmptySchemaError,
50
- "ROM::Relation[Tasks] relation has no schema. Make sure :auto_restrictions is enabled after defining a schema"
51
- )
52
- end
53
42
  end
54
43
  end
@@ -19,6 +19,30 @@ RSpec.describe 'Inferring schema from database' do
19
19
  end
20
20
 
21
21
  context 'defining associations', seeds: false do
22
+ let(:config) { TestConfiguration.new(:sql, conn) }
23
+ let(:container) { ROM.container(config) }
24
+
25
+ let(:user_associations) do
26
+ config.relation(:accounts) { schema(infer: true) }
27
+ config.relation(:cards) { schema(infer: true) }
28
+ config.register_relation(Test::Users)
29
+ container.relations[:users].associations
30
+ end
31
+
32
+ let(:post_associations) do
33
+ config.relation(:tags) { schema(infer: true) }
34
+ config.relation(:posts_tags) { schema(infer: true) }
35
+ config.register_relation(Test::Posts)
36
+ container.relations[:posts].associations
37
+ end
38
+
39
+ let(:tag_associations) do
40
+ config.relation(:posts) { schema(infer: true) }
41
+ config.relation(:posts_tags) { schema(infer: true) }
42
+ config.register_relation(Test::Tags)
43
+ container.relations[:tags].associations
44
+ end
45
+
22
46
  it "allows defining a one-to-many" do
23
47
  class Test::Posts < ROM::Relation[:sql]
24
48
  schema(:posts) do
@@ -28,9 +52,9 @@ RSpec.describe 'Inferring schema from database' do
28
52
  end
29
53
  end
30
54
 
31
- assoc = ROM::SQL::Association::OneToMany.new(:posts, :tags)
55
+ assoc = ROM::Associations::Definitions::OneToMany.new(:posts, :tags)
32
56
 
33
- expect(Test::Posts.associations[:tags]).to eql(assoc)
57
+ expect(post_associations[:tags].definition).to eql(assoc)
34
58
  end
35
59
 
36
60
  it "allows defining a one-to-many using has_many shortcut" do
@@ -42,9 +66,9 @@ RSpec.describe 'Inferring schema from database' do
42
66
  end
43
67
  end
44
68
 
45
- assoc = ROM::SQL::Association::OneToMany.new(:posts, :tags)
69
+ assoc = ROM::Associations::Definitions::OneToMany.new(:posts, :tags)
46
70
 
47
- expect(Test::Posts.associations[:tags]).to eql(assoc)
71
+ expect(post_associations[:tags].definition).to eql(assoc)
48
72
  end
49
73
 
50
74
  it "allows defining a one-to-one" do
@@ -56,9 +80,9 @@ RSpec.describe 'Inferring schema from database' do
56
80
  end
57
81
  end
58
82
 
59
- assoc = ROM::SQL::Association::OneToOne.new(:users, :accounts)
83
+ assoc = ROM::Associations::Definitions::OneToOne.new(:users, :accounts)
60
84
 
61
- expect(Test::Users.associations[:accounts]).to eql(assoc)
85
+ expect(user_associations[:accounts].definition).to eql(assoc)
62
86
  end
63
87
 
64
88
  it "allows defining a one-to-one using has_one shortcut" do
@@ -70,10 +94,10 @@ RSpec.describe 'Inferring schema from database' do
70
94
  end
71
95
  end
72
96
 
73
- assoc = ROM::SQL::Association::OneToOne.new(:users, :accounts, as: :account)
97
+ assoc = ROM::Associations::Definitions::OneToOne.new(:users, :accounts, as: :account)
74
98
 
75
- expect(Test::Users.associations[:account]).to eql(assoc)
76
- expect(Test::Users.associations[:account].target).to be_aliased
99
+ expect(user_associations[:account].definition).to eql(assoc)
100
+ expect(user_associations[:account].definition.target).to be_aliased
77
101
  end
78
102
 
79
103
  it "allows defining a one-to-one using has_one shortcut with an alias" do
@@ -85,10 +109,10 @@ RSpec.describe 'Inferring schema from database' do
85
109
  end
86
110
  end
87
111
 
88
- assoc = ROM::SQL::Association::OneToOne.new(:users, :accounts, as: :user_account)
112
+ assoc = ROM::Associations::Definitions::OneToOne.new(:users, :accounts, as: :user_account)
89
113
 
90
- expect(Test::Users.associations[:user_account]).to eql(assoc)
91
- expect(Test::Users.associations[:user_account].target).to be_aliased
114
+ expect(user_associations[:user_account].definition).to eql(assoc)
115
+ expect(user_associations[:user_account].definition.target).to be_aliased
92
116
  end
93
117
 
94
118
  it "allows defining a one-to-one-through" do
@@ -100,9 +124,9 @@ RSpec.describe 'Inferring schema from database' do
100
124
  end
101
125
  end
102
126
 
103
- assoc = ROM::SQL::Association::OneToOneThrough.new(:users, :cards, through: :accounts)
127
+ assoc = ROM::Associations::Definitions::OneToOneThrough.new(:users, :cards, through: :accounts)
104
128
 
105
- expect(Test::Users.associations[:cards]).to eql(assoc)
129
+ expect(user_associations[:cards].definition).to eql(assoc)
106
130
  end
107
131
 
108
132
  it "allows defining a many-to-one" do
@@ -114,9 +138,9 @@ RSpec.describe 'Inferring schema from database' do
114
138
  end
115
139
  end
116
140
 
117
- assoc = ROM::SQL::Association::ManyToOne.new(:tags, :posts)
141
+ assoc = ROM::Associations::Definitions::ManyToOne.new(:tags, :posts)
118
142
 
119
- expect(Test::Tags.associations[:posts]).to eql(assoc)
143
+ expect(tag_associations[:posts].definition).to eql(assoc)
120
144
  end
121
145
 
122
146
  it "allows defining a many-to-one using belongs_to shortcut" do
@@ -128,9 +152,9 @@ RSpec.describe 'Inferring schema from database' do
128
152
  end
129
153
  end
130
154
 
131
- assoc = ROM::SQL::Association::ManyToOne.new(:tags, :posts, as: :post)
155
+ assoc = ROM::Associations::Definitions::ManyToOne.new(:tags, :posts, as: :post)
132
156
 
133
- expect(Test::Tags.associations[:post]).to eql(assoc)
157
+ expect(tag_associations[:post].definition).to eql(assoc)
134
158
  end
135
159
 
136
160
  it "allows defining a many-to-one using belongs_to shortcut" do
@@ -142,9 +166,9 @@ RSpec.describe 'Inferring schema from database' do
142
166
  end
143
167
  end
144
168
 
145
- assoc = ROM::SQL::Association::ManyToOne.new(:tags, :posts, as: :post_tag)
169
+ assoc = ROM::Associations::Definitions::ManyToOne.new(:tags, :posts, as: :post_tag)
146
170
 
147
- expect(Test::Tags.associations[:post_tag]).to eql(assoc)
171
+ expect(tag_associations[:post_tag].definition).to eql(assoc)
148
172
  end
149
173
 
150
174
  it "allows defining a many-to-many" do
@@ -156,23 +180,23 @@ RSpec.describe 'Inferring schema from database' do
156
180
  end
157
181
  end
158
182
 
159
- assoc = ROM::SQL::Association::ManyToMany.new(:posts, :tags, through: :posts_tags)
183
+ assoc = ROM::Associations::Definitions::ManyToMany.new(:posts, :tags, through: :posts_tags)
160
184
 
161
- expect(Test::Posts.associations[:tags]).to eql(assoc)
185
+ expect(post_associations[:tags].definition).to eql(assoc)
162
186
  end
163
187
 
164
188
  it "allows defining a many-to-one with a custom name" do
165
189
  class Test::Tags < ROM::Relation[:sql]
166
190
  schema(:tags) do
167
191
  associations do
168
- many_to_one :published_posts, relation: :posts
192
+ many_to_one :posts, as: :published_posts
169
193
  end
170
194
  end
171
195
  end
172
196
 
173
- assoc = ROM::SQL::Association::ManyToOne.new(:tags, :published_posts, relation: :posts)
197
+ assoc = ROM::Associations::Definitions::ManyToOne.new(:tags, :posts, as: :published_posts)
174
198
 
175
- expect(Test::Tags.associations[:published_posts]).to eql(assoc)
199
+ expect(tag_associations[:published_posts].definition).to eql(assoc)
176
200
  end
177
201
  end
178
202
  end
@@ -63,7 +63,7 @@ RSpec.describe 'ROM::SQL::Schema::PostgresInferrer', :postgres do
63
63
  jsonb_data: ROM::SQL::Types::PG::JSONB.optional.meta(name: :jsonb_data, source: source),
64
64
  money: ROM::SQL::Types::Decimal.meta(name: :money, source: source),
65
65
  tags: ROM::SQL::Types::PG::Array('text').optional.meta(name: :tags, source: source),
66
- tag_ids: ROM::SQL::Types::PG::Array('bigint').optional.meta(name: :tag_ids, source: source),
66
+ tag_ids: ROM::SQL::Types::PG::Array('biging').optional.meta(name: :tag_ids, source: source),
67
67
  color: ROM::SQL::Types::String.enum(*colors).optional.meta(name: :color, source: source),
68
68
  ip: ROM::SQL::Types::PG::IPAddress.optional.meta(
69
69
  name: :ip,
@@ -39,12 +39,6 @@ RSpec.describe 'Schema inference for common datatypes', seeds: false do
39
39
  let(:source) { ROM::Relation::Name[:tasks] }
40
40
 
41
41
  it 'can infer attributes for dataset' do |ex|
42
- if mysql?(ex)
43
- indexes = { index: %i(user_id).to_set }
44
- else
45
- indexes = {}
46
- end
47
-
48
42
  expect(schema.to_h).
49
43
  to eql(
50
44
  id: ROM::SQL::Types::Serial.meta(name: :id, source: source),
@@ -53,8 +47,7 @@ RSpec.describe 'Schema inference for common datatypes', seeds: false do
53
47
  name: :user_id,
54
48
  foreign_key: true,
55
49
  source: source,
56
- target: :users,
57
- **indexes
50
+ target: :users
58
51
  )
59
52
  )
60
53
  end
@@ -189,11 +182,11 @@ RSpec.describe 'Schema inference for common datatypes', seeds: false do
189
182
  inferrable_relations.concat %i(people)
190
183
  end
191
184
 
192
- let(:relation) { container.relation(:people) }
185
+ let(:relation) { container.relations[:people] }
193
186
 
194
187
  before do
195
188
  conf.relation(:people) do
196
- schema(dataset, infer: true)
189
+ schema(infer: true)
197
190
  end
198
191
 
199
192
  conf.commands(:people) do
@@ -356,20 +349,16 @@ RSpec.describe 'Schema inference for common datatypes', seeds: false do
356
349
 
357
350
  index %i(bar baz), name: :composite_idx
358
351
  end
352
+
353
+ conf.relation(:test_inferrence) { schema(infer: true) }
359
354
  end
360
355
 
361
356
  let(:dataset) { :test_inferrence }
362
357
  let(:source) { ROM::Relation::Name[dataset] }
363
358
 
364
359
  it 'infers types with indices' do
365
- int = ROM::SQL::Types::Int
366
- expect(schema.to_h).
367
- to eql(
368
- id: int.meta(name: :id, source: source, primary_key: true),
369
- foo: int.optional.meta(name: :foo, source: source, index: %i(foo_idx).to_set),
370
- bar: int.meta(name: :bar, source: source, index: %i(bar_idx composite_idx).to_set),
371
- baz: int.meta(name: :baz, source: source, index: %i(baz1_idx baz2_idx).to_set)
372
- )
360
+ expect(schema.indexes.map(&:name)).
361
+ to match_array(%i(foo_idx bar_idx baz1_idx baz2_idx composite_idx))
373
362
  end
374
363
  end
375
364
  end
@@ -8,6 +8,10 @@ RSpec.describe 'ROM.container' do
8
8
  primary_key :id
9
9
  column :name, String
10
10
  end
11
+
12
+ conf.relation(:dragons) do
13
+ schema(infer: true)
14
+ end
11
15
  end
12
16
  end
13
17
 
@@ -1,12 +1,12 @@
1
- RSpec.describe 'Plugins / :auto_wrap' do
1
+ RSpec.describe ROM::SQL::Wrap do
2
2
  with_adapters do
3
3
  include_context 'users and tasks'
4
4
 
5
- describe '#for_wrap' do
5
+ describe '#wrap' do
6
6
  shared_context 'joined tuple' do
7
- it 'returns joined tuples' do
7
+ it 'returns nested tuples' do
8
8
  task_with_user = tasks
9
- .for_wrap({ id: :user_id }, name)
9
+ .wrap(name)
10
10
  .where { id.qualified.is(2) }
11
11
  .one
12
12
 
@@ -17,7 +17,7 @@ RSpec.describe 'Plugins / :auto_wrap' do
17
17
 
18
18
  it 'works with by_pk' do
19
19
  task_with_user = tasks
20
- .for_wrap({ id: :user_id }, users.name.relation)
20
+ .wrap(name)
21
21
  .by_pk(1)
22
22
  .one
23
23
 
@@ -26,42 +26,17 @@ RSpec.describe 'Plugins / :auto_wrap' do
26
26
  end
27
27
  end
28
28
 
29
- context 'when parent relation is registered under dataset name' do
30
- before do
31
- conf.relation(:tasks) { schema(infer: true) }
32
- conf.relation(:users) { schema(infer: true) }
33
- end
34
-
35
- include_context 'joined tuple' do
36
- let(:name) { :users }
37
- end
38
- end
39
-
40
- context 'when parent relation is registered under a custom name' do
41
- before do
42
- conf.relation(:tasks) { schema(infer: true) }
43
- conf.relation(:authors) { schema(:users, infer: true) }
44
- end
45
-
46
- include_context 'joined tuple' do
47
- let(:users) { relations[:authors] }
48
- let(:name) { :authors}
49
- end
50
- end
51
-
52
29
  context 'using association with inferred relation name' do
53
30
  before do
54
31
  conf.relation(:tasks) do
32
+ auto_map false
33
+
55
34
  schema(infer: true) do
56
35
  associations do
57
36
  belongs_to :user
58
37
  end
59
38
  end
60
39
  end
61
-
62
- conf.relation(:users) do
63
- schema(infer: true)
64
- end
65
40
  end
66
41
 
67
42
  include_context 'joined tuple' do
@@ -72,16 +47,14 @@ RSpec.describe 'Plugins / :auto_wrap' do
72
47
  context 'using association with an alias' do
73
48
  before do
74
49
  conf.relation(:tasks) do
50
+ auto_map false
51
+
75
52
  schema(infer: true) do
76
53
  associations do
77
54
  belongs_to :users, as: :assignee
78
55
  end
79
56
  end
80
57
  end
81
-
82
- conf.relation(:users) do
83
- schema(infer: true)
84
- end
85
58
  end
86
59
 
87
60
  include_context 'joined tuple' do
@@ -92,6 +65,8 @@ RSpec.describe 'Plugins / :auto_wrap' do
92
65
  context 'using association with an aliased relation' do
93
66
  before do
94
67
  conf.relation(:tasks) do
68
+ auto_map false
69
+
95
70
  schema(infer: true) do
96
71
  associations do
97
72
  belongs_to :users, as: :assignee, relation: :people
@@ -100,6 +75,8 @@ RSpec.describe 'Plugins / :auto_wrap' do
100
75
  end
101
76
 
102
77
  conf.relation(:people) do
78
+ auto_map false
79
+
103
80
  schema(:users, infer: true)
104
81
  end
105
82
  end
@@ -32,6 +32,10 @@ RSpec.shared_context 'accounts' do
32
32
  Integer :card_id
33
33
  String :service
34
34
  end
35
+
36
+ conf.relation(:accounts) { schema(infer: true) }
37
+ conf.relation(:cards) { schema(infer: true) }
38
+ conf.relation(:subscriptions) { schema(infer: true) }
35
39
  end
36
40
 
37
41
  before do |example|
@@ -29,13 +29,14 @@ RSpec.shared_context 'database setup' do
29
29
  let(:conn) { Sequel.connect(uri) }
30
30
  let(:database_type) { conn.database_type }
31
31
  let(:inferrable_relations) { [] }
32
- let(:conf) { ROM::Configuration.new(:sql, conn, inferrable_relations: inferrable_relations) }
32
+ let(:conf) { TestConfiguration.new(:sql, conn) }
33
33
  let(:container) { ROM.container(conf) }
34
34
  let(:relations) { container.relations }
35
35
  let(:commands) { container.commands }
36
36
 
37
37
  before do
38
38
  conn.loggers << LOGGER
39
+ inferrable_relations.each { |name| conf.relation(name) { schema(infer: true) } }
39
40
  end
40
41
 
41
42
  after do
data/spec/shared/notes.rb CHANGED
@@ -17,5 +17,7 @@ RSpec.shared_context 'notes' do
17
17
  DateTime :completed_at
18
18
  Date :written
19
19
  end
20
+
21
+ conf.relation(:notes) { schema(infer: true) }
20
22
  end
21
23
  end
data/spec/shared/posts.rb CHANGED
@@ -10,6 +10,8 @@ RSpec.shared_context 'posts' do
10
10
  String :title
11
11
  String :body
12
12
  end
13
+
14
+ conf.relation(:posts) { schema(infer: true) }
13
15
  end
14
16
 
15
17
  before do |example|
@@ -9,5 +9,7 @@ RSpec.shared_context 'puppies' do
9
9
  String :name, null: false
10
10
  boolean :cute, null: false, default: true
11
11
  end
12
+
13
+ conf.relation(:puppies) { schema(infer: true) }
12
14
  end
13
15
  end
@@ -2,7 +2,7 @@ RSpec.shared_context 'relations' do
2
2
  include_context 'users and tasks'
3
3
 
4
4
  before do
5
- conf.relation(:users)
6
- conf.relation(:tasks)
5
+ conf.relation(:users) { schema(infer: true) }
6
+ conf.relation(:tasks) { schema(infer: true) }
7
7
  end
8
8
  end
data/spec/shared/users.rb CHANGED
@@ -19,6 +19,8 @@ RSpec.shared_context 'users' do
19
19
  String :name, text: false, null: false
20
20
  check { char_length(name) > 2 } if ctx.postgres?(example)
21
21
  end
22
+
23
+ conf.relation(:users) { schema(infer: true) }
22
24
  end
23
25
 
24
26
  before do |example|