torque-postgresql 2.2.4 → 2.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.
@@ -42,18 +42,19 @@ RSpec.describe 'Enum' do
42
42
  end
43
43
 
44
44
  context 'on schema' do
45
+ let(:dump_result) do
46
+ ActiveRecord::SchemaDumper.dump(connection, (dump_result = StringIO.new))
47
+ dump_result.string
48
+ end
49
+
45
50
  it 'can be used on tables' do
46
- dump_io = StringIO.new
47
51
  checker = /t\.enum +"conflicts", +array: true, +enum_type: :conflicts/
48
- ActiveRecord::SchemaDumper.dump(connection, dump_io)
49
- expect(dump_io.string).to match checker
52
+ expect(dump_result).to match checker
50
53
  end
51
54
 
52
55
  xit 'can have a default value as an array of symbols' do
53
- dump_io = StringIO.new
54
56
  checker = /t\.enum +"types", +default: \[:A, :B\], +array: true, +enum_type: :types/
55
- ActiveRecord::SchemaDumper.dump(connection, dump_io)
56
- expect(dump_io.string).to match checker
57
+ expect(dump_result).to match checker
57
58
  end
58
59
  end
59
60
 
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Schema' do
4
+ let(:connection) { ActiveRecord::Base.connection }
5
+
6
+ before do
7
+ connection.instance_variable_set(:@schmeas_blacklist, nil)
8
+ connection.instance_variable_set(:@schmeas_whitelist, nil)
9
+ end
10
+
11
+ context 'on migration' do
12
+ it 'can check for existance' do
13
+ expect(connection.schema_exists?(:information_schema)).to be_falsey
14
+ expect(connection.schema_exists?(:information_schema, filtered: false)).to be_truthy
15
+ end
16
+
17
+ it 'can be created' do
18
+ expect(connection.schema_exists?(:legacy, filtered: false)).to be_falsey
19
+ connection.create_schema(:legacy)
20
+ expect(connection.schema_exists?(:legacy, filtered: false)).to be_truthy
21
+ end
22
+
23
+ it 'can be deleted' do
24
+ expect(connection.schema_exists?(:legacy, filtered: false)).to be_falsey
25
+
26
+ connection.create_schema(:legacy)
27
+ expect(connection.schema_exists?(:legacy, filtered: false)).to be_truthy
28
+
29
+ connection.drop_schema(:legacy)
30
+ expect(connection.schema_exists?(:legacy, filtered: false)).to be_falsey
31
+ end
32
+
33
+ it 'works with whitelist' do
34
+ expect(connection.schema_exists?(:legacy)).to be_falsey
35
+ connection.create_schema(:legacy)
36
+
37
+ expect(connection.schema_exists?(:legacy)).to be_falsey
38
+ expect(connection.schema_exists?(:legacy, filtered: false)).to be_truthy
39
+
40
+ connection.schemas_whitelist.push('legacy')
41
+ expect(connection.schema_exists?(:legacy)).to be_truthy
42
+ end
43
+ end
44
+
45
+ context 'on schema' do
46
+ let(:dump_result) do
47
+ ActiveRecord::SchemaDumper.dump(connection, (dump_result = StringIO.new))
48
+ dump_result.string
49
+ end
50
+
51
+ it 'does not add when there is no extra schemas' do
52
+ connection.drop_schema(:internal, force: :cascade)
53
+ expect(dump_result).not_to match /Custom schemas defined in this database/
54
+ end
55
+
56
+ it 'does not include tables from blacklisted schemas' do
57
+ connection.schemas_blacklist.push('internal')
58
+ expect(dump_result).not_to match /create_table \"users\",.*schema: +"internal"/
59
+ end
60
+
61
+ context 'with internal schema whitelisted' do
62
+ before { connection.schemas_whitelist.push('internal') }
63
+
64
+ it 'dumps the schemas' do
65
+ expect(dump_result).to match /create_schema \"internal\"/
66
+ end
67
+
68
+ it 'shows the internal users table in the connection tables list' do
69
+ expect(connection.tables).to include('internal.users')
70
+ end
71
+
72
+ it 'dumps tables on whitelisted schemas' do
73
+ expect(dump_result).to match /create_table \"users\",.*schema: +"internal"/
74
+ end
75
+ end
76
+ end
77
+
78
+ context 'on relation' do
79
+ let(:model) { Internal::User }
80
+
81
+ it 'adds the schema to the query' do
82
+ expect(model.all.to_sql).to match(/FROM "internal"."users"/)
83
+ end
84
+
85
+ it 'can load the schema from the module' do
86
+ allow(Internal).to receive(:schema).and_return('internal')
87
+ allow(model).to receive(:schema).and_return(nil)
88
+
89
+ expect(model.all.to_sql).to match(/FROM "internal"."users"/)
90
+ end
91
+ end
92
+ end
@@ -73,37 +73,33 @@ RSpec.describe 'TableInheritance' do
73
73
  end
74
74
 
75
75
  context 'on schema' do
76
- it 'dumps single inheritance with body' do
77
- dump_io = StringIO.new
78
- ActiveRecord::SchemaDumper.dump(connection, dump_io)
76
+ let(:dump_result) do
77
+ ActiveRecord::SchemaDumper.dump(connection, (dump_result = StringIO.new))
78
+ dump_result.string
79
+ end
79
80
 
81
+ it 'dumps single inheritance with body' do
80
82
  parts = '"activity_books"'
81
83
  parts << ', id: false'
82
84
  parts << ', force: :cascade'
83
- parts << ', inherits: :activities'
84
- expect(dump_io.string).to match(/create_table #{parts} do /)
85
+ parts << ', inherits: "activities"'
86
+ expect(dump_result).to match(/create_table #{parts} do /)
85
87
  end
86
88
 
87
89
  it 'dumps single inheritance without body' do
88
- dump_io = StringIO.new
89
- ActiveRecord::SchemaDumper.dump(connection, dump_io)
90
-
91
90
  parts = '"activity_post_samples"'
92
91
  parts << ', id: false'
93
92
  parts << ', force: :cascade'
94
- parts << ', inherits: :activity_posts'
95
- expect(dump_io.string).to match(/create_table #{parts}(?! do \|t\|)/)
93
+ parts << ', inherits: "activity_posts"'
94
+ expect(dump_result).to match(/create_table #{parts}(?! do \|t\|)/)
96
95
  end
97
96
 
98
97
  it 'dumps multiple inheritance' do
99
- dump_io = StringIO.new
100
- ActiveRecord::SchemaDumper.dump(connection, dump_io)
101
-
102
98
  parts = '"activity_posts"'
103
99
  parts << ', id: false'
104
100
  parts << ', force: :cascade'
105
- parts << ', inherits: (\[:images, :activities\]|\[:activities, :images\])'
106
- expect(dump_io.string).to match(/create_table #{parts}/)
101
+ parts << ', inherits: (\["images", "activities"\]|\["activities", "images"\])'
102
+ expect(dump_result).to match(/create_table #{parts}/)
107
103
  end
108
104
  end
109
105
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torque-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-11 00:00:00.000000000 Z
11
+ date: 2022-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '6.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: pg
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -102,22 +108,22 @@ dependencies:
102
108
  name: rspec
103
109
  requirement: !ruby/object:Gem::Requirement
104
110
  requirements:
105
- - - "~>"
106
- - !ruby/object:Gem::Version
107
- version: '3.5'
108
111
  - - ">="
109
112
  - !ruby/object:Gem::Version
110
113
  version: 3.5.0
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.5'
111
117
  type: :development
112
118
  prerelease: false
113
119
  version_requirements: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.5'
118
121
  - - ">="
119
122
  - !ruby/object:Gem::Version
120
123
  version: 3.5.0
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '3.5'
121
127
  - !ruby/object:Gem::Dependency
122
128
  name: factory_bot
123
129
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +161,7 @@ dependencies:
155
161
  description: Add support to complex resources of PostgreSQL, like data types, array
156
162
  associations, and auxiliary statements (CTE)
157
163
  email:
158
- - carlinhus.fsilva@gmail.com
164
+ - me@carlosfsilva.com
159
165
  executables: []
160
166
  extensions: []
161
167
  extra_rdoc_files: []
@@ -207,6 +213,7 @@ files:
207
213
  - lib/torque/postgresql/attributes/period.rb
208
214
  - lib/torque/postgresql/autosave_association.rb
209
215
  - lib/torque/postgresql/auxiliary_statement.rb
216
+ - lib/torque/postgresql/auxiliary_statement/recursive.rb
210
217
  - lib/torque/postgresql/auxiliary_statement/settings.rb
211
218
  - lib/torque/postgresql/base.rb
212
219
  - lib/torque/postgresql/collector.rb
@@ -231,6 +238,7 @@ files:
231
238
  - lib/torque/postgresql/relation/inheritance.rb
232
239
  - lib/torque/postgresql/relation/merger.rb
233
240
  - lib/torque/postgresql/schema_cache.rb
241
+ - lib/torque/postgresql/table_name.rb
234
242
  - lib/torque/postgresql/version.rb
235
243
  - lib/torque/range.rb
236
244
  - spec/en.yml
@@ -250,10 +258,12 @@ files:
250
258
  - spec/models/activity_post/sample.rb
251
259
  - spec/models/author.rb
252
260
  - spec/models/author_journalist.rb
261
+ - spec/models/category.rb
253
262
  - spec/models/comment.rb
254
263
  - spec/models/course.rb
255
264
  - spec/models/geometry.rb
256
265
  - spec/models/guest_comment.rb
266
+ - spec/models/internal/user.rb
257
267
  - spec/models/item.rb
258
268
  - spec/models/post.rb
259
269
  - spec/models/question.rb
@@ -281,13 +291,18 @@ files:
281
291
  - spec/tests/quoting_spec.rb
282
292
  - spec/tests/range_spec.rb
283
293
  - spec/tests/relation_spec.rb
294
+ - spec/tests/schema_spec.rb
284
295
  - spec/tests/table_inheritance_spec.rb
285
296
  homepage: https://github.com/crashtech/torque-postgresql
286
297
  licenses:
287
298
  - MIT
288
- metadata: {}
289
- post_install_message:
290
- rdoc_options: []
299
+ metadata:
300
+ source_code_uri: https://github.com/crashtech/torque-postgresql
301
+ bug_tracker_uri: https://github.com/crashtech/torque-postgresql/issues
302
+ post_install_message:
303
+ rdoc_options:
304
+ - "--title"
305
+ - Torque PostgreSQL
291
306
  require_paths:
292
307
  - lib
293
308
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -301,57 +316,60 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
316
  - !ruby/object:Gem::Version
302
317
  version: 1.8.11
303
318
  requirements: []
304
- rubygems_version: 3.2.15
305
- signing_key:
319
+ rubygems_version: 3.0.8
320
+ signing_key:
306
321
  specification_version: 4
307
322
  summary: ActiveRecord extension to access PostgreSQL advanced resources
308
323
  test_files:
309
324
  - spec/en.yml
310
325
  - spec/factories/authors.rb
311
326
  - spec/factories/comments.rb
312
- - spec/factories/item.rb
313
327
  - spec/factories/posts.rb
314
328
  - spec/factories/tags.rb
315
329
  - spec/factories/texts.rb
316
330
  - spec/factories/users.rb
317
331
  - spec/factories/videos.rb
332
+ - spec/factories/item.rb
318
333
  - spec/mocks/cache_query.rb
319
334
  - spec/mocks/create_table.rb
320
335
  - spec/models/activity.rb
321
336
  - spec/models/activity_book.rb
322
- - spec/models/activity_post/sample.rb
323
337
  - spec/models/activity_post.rb
338
+ - spec/models/activity_post/sample.rb
324
339
  - spec/models/author.rb
325
340
  - spec/models/author_journalist.rb
326
341
  - spec/models/comment.rb
327
342
  - spec/models/course.rb
328
343
  - spec/models/geometry.rb
329
344
  - spec/models/guest_comment.rb
330
- - spec/models/item.rb
331
345
  - spec/models/post.rb
332
- - spec/models/question.rb
333
- - spec/models/question_select.rb
334
346
  - spec/models/tag.rb
335
347
  - spec/models/text.rb
336
348
  - spec/models/time_keeper.rb
337
349
  - spec/models/user.rb
338
350
  - spec/models/video.rb
339
- - spec/schema.rb
340
- - spec/spec_helper.rb
341
- - spec/tests/arel_spec.rb
342
- - spec/tests/auxiliary_statement_spec.rb
343
- - spec/tests/belongs_to_many_spec.rb
351
+ - spec/models/item.rb
352
+ - spec/models/question.rb
353
+ - spec/models/question_select.rb
354
+ - spec/models/internal/user.rb
355
+ - spec/models/category.rb
344
356
  - spec/tests/collector_spec.rb
345
357
  - spec/tests/distinct_on_spec.rb
346
- - spec/tests/enum_set_spec.rb
347
- - spec/tests/enum_spec.rb
348
358
  - spec/tests/geometric_builder_spec.rb
349
- - spec/tests/has_many_spec.rb
350
- - spec/tests/insert_all_spec.rb
351
- - spec/tests/interval_spec.rb
352
359
  - spec/tests/lazy_spec.rb
353
- - spec/tests/period_spec.rb
354
360
  - spec/tests/quoting_spec.rb
355
- - spec/tests/range_spec.rb
356
361
  - spec/tests/relation_spec.rb
362
+ - spec/tests/belongs_to_many_spec.rb
363
+ - spec/tests/range_spec.rb
364
+ - spec/tests/insert_all_spec.rb
365
+ - spec/tests/enum_set_spec.rb
366
+ - spec/tests/auxiliary_statement_spec.rb
367
+ - spec/tests/interval_spec.rb
368
+ - spec/tests/period_spec.rb
369
+ - spec/tests/schema_spec.rb
357
370
  - spec/tests/table_inheritance_spec.rb
371
+ - spec/tests/arel_spec.rb
372
+ - spec/tests/enum_spec.rb
373
+ - spec/tests/has_many_spec.rb
374
+ - spec/spec_helper.rb
375
+ - spec/schema.rb