torque-postgresql 1.1.7 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/torque/postgresql.rb +0 -2
  3. data/lib/torque/postgresql/adapter.rb +7 -1
  4. data/lib/torque/postgresql/adapter/database_statements.rb +6 -15
  5. data/lib/torque/postgresql/adapter/oid.rb +3 -1
  6. data/lib/torque/postgresql/adapter/oid/box.rb +2 -0
  7. data/lib/torque/postgresql/adapter/oid/circle.rb +2 -0
  8. data/lib/torque/postgresql/adapter/oid/enum.rb +2 -0
  9. data/lib/torque/postgresql/adapter/oid/enum_set.rb +2 -0
  10. data/lib/torque/postgresql/adapter/oid/interval.rb +2 -0
  11. data/lib/torque/postgresql/adapter/oid/line.rb +2 -0
  12. data/lib/torque/postgresql/adapter/oid/range.rb +2 -0
  13. data/lib/torque/postgresql/adapter/oid/segment.rb +2 -0
  14. data/lib/torque/postgresql/adapter/quoting.rb +2 -0
  15. data/lib/torque/postgresql/adapter/schema_creation.rb +20 -23
  16. data/lib/torque/postgresql/adapter/schema_definitions.rb +9 -21
  17. data/lib/torque/postgresql/adapter/schema_dumper.rb +76 -11
  18. data/lib/torque/postgresql/adapter/schema_statements.rb +4 -12
  19. data/lib/torque/postgresql/arel/infix_operation.rb +5 -1
  20. data/lib/torque/postgresql/arel/join_source.rb +2 -0
  21. data/lib/torque/postgresql/arel/nodes.rb +2 -0
  22. data/lib/torque/postgresql/arel/operations.rb +2 -0
  23. data/lib/torque/postgresql/arel/select_manager.rb +2 -0
  24. data/lib/torque/postgresql/arel/visitors.rb +6 -3
  25. data/lib/torque/postgresql/associations.rb +0 -3
  26. data/lib/torque/postgresql/associations/association.rb +5 -1
  27. data/lib/torque/postgresql/associations/association_scope.rb +20 -60
  28. data/lib/torque/postgresql/associations/belongs_to_many_association.rb +5 -1
  29. data/lib/torque/postgresql/associations/builder/belongs_to_many.rb +2 -0
  30. data/lib/torque/postgresql/associations/builder/has_many.rb +2 -0
  31. data/lib/torque/postgresql/associations/preloader.rb +0 -32
  32. data/lib/torque/postgresql/associations/preloader/association.rb +42 -10
  33. data/lib/torque/postgresql/attributes/builder.rb +2 -0
  34. data/lib/torque/postgresql/attributes/builder/enum.rb +5 -3
  35. data/lib/torque/postgresql/attributes/builder/period.rb +6 -4
  36. data/lib/torque/postgresql/attributes/enum.rb +5 -10
  37. data/lib/torque/postgresql/attributes/enum_set.rb +2 -0
  38. data/lib/torque/postgresql/attributes/lazy.rb +3 -1
  39. data/lib/torque/postgresql/attributes/period.rb +2 -0
  40. data/lib/torque/postgresql/autosave_association.rb +9 -3
  41. data/lib/torque/postgresql/auxiliary_statement.rb +3 -13
  42. data/lib/torque/postgresql/auxiliary_statement/settings.rb +2 -0
  43. data/lib/torque/postgresql/base.rb +2 -0
  44. data/lib/torque/postgresql/coder.rb +6 -5
  45. data/lib/torque/postgresql/collector.rb +2 -0
  46. data/lib/torque/postgresql/config.rb +3 -4
  47. data/lib/torque/postgresql/geometry_builder.rb +2 -0
  48. data/lib/torque/postgresql/i18n.rb +2 -0
  49. data/lib/torque/postgresql/inheritance.rb +15 -17
  50. data/lib/torque/postgresql/migration/command_recorder.rb +2 -0
  51. data/lib/torque/postgresql/railtie.rb +2 -0
  52. data/lib/torque/postgresql/reflection.rb +2 -0
  53. data/lib/torque/postgresql/reflection/abstract_reflection.rb +28 -26
  54. data/lib/torque/postgresql/reflection/association_reflection.rb +2 -0
  55. data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +6 -26
  56. data/lib/torque/postgresql/reflection/has_many_reflection.rb +2 -0
  57. data/lib/torque/postgresql/reflection/runtime_reflection.rb +2 -0
  58. data/lib/torque/postgresql/reflection/through_reflection.rb +2 -0
  59. data/lib/torque/postgresql/relation.rb +10 -11
  60. data/lib/torque/postgresql/relation/auxiliary_statement.rb +7 -8
  61. data/lib/torque/postgresql/relation/distinct_on.rb +3 -1
  62. data/lib/torque/postgresql/relation/inheritance.rb +2 -0
  63. data/lib/torque/postgresql/relation/merger.rb +2 -0
  64. data/lib/torque/postgresql/schema_cache.rb +2 -0
  65. data/lib/torque/postgresql/version.rb +3 -1
  66. data/spec/en.yml +19 -0
  67. data/spec/factories/authors.rb +6 -0
  68. data/spec/factories/comments.rb +13 -0
  69. data/spec/factories/posts.rb +6 -0
  70. data/spec/factories/tags.rb +5 -0
  71. data/spec/factories/texts.rb +5 -0
  72. data/spec/factories/users.rb +6 -0
  73. data/spec/factories/videos.rb +5 -0
  74. data/spec/mocks/cache_query.rb +16 -0
  75. data/spec/mocks/create_table.rb +35 -0
  76. data/spec/models/activity.rb +3 -0
  77. data/spec/models/activity_book.rb +4 -0
  78. data/spec/models/activity_post.rb +7 -0
  79. data/spec/models/activity_post/sample.rb +4 -0
  80. data/spec/models/author.rb +4 -0
  81. data/spec/models/author_journalist.rb +4 -0
  82. data/spec/models/comment.rb +3 -0
  83. data/spec/models/course.rb +2 -0
  84. data/spec/models/geometry.rb +2 -0
  85. data/spec/models/guest_comment.rb +4 -0
  86. data/spec/models/post.rb +6 -0
  87. data/spec/models/tag.rb +2 -0
  88. data/spec/models/text.rb +2 -0
  89. data/spec/models/time_keeper.rb +2 -0
  90. data/spec/models/user.rb +8 -0
  91. data/spec/models/video.rb +2 -0
  92. data/spec/schema.rb +141 -0
  93. data/spec/spec_helper.rb +59 -0
  94. data/spec/tests/arel_spec.rb +74 -0
  95. data/spec/tests/auxiliary_statement_spec.rb +593 -0
  96. data/spec/tests/belongs_to_many_spec.rb +246 -0
  97. data/spec/tests/coder_spec.rb +367 -0
  98. data/spec/tests/collector_spec.rb +59 -0
  99. data/spec/tests/distinct_on_spec.rb +65 -0
  100. data/spec/tests/enum_set_spec.rb +306 -0
  101. data/spec/tests/enum_spec.rb +628 -0
  102. data/spec/tests/geometric_builder_spec.rb +221 -0
  103. data/spec/tests/has_many_spec.rb +400 -0
  104. data/spec/tests/interval_spec.rb +167 -0
  105. data/spec/tests/lazy_spec.rb +24 -0
  106. data/spec/tests/period_spec.rb +954 -0
  107. data/spec/tests/quoting_spec.rb +24 -0
  108. data/spec/tests/range_spec.rb +36 -0
  109. data/spec/tests/relation_spec.rb +57 -0
  110. data/spec/tests/table_inheritance_spec.rb +416 -0
  111. metadata +102 -14
  112. data/lib/torque/postgresql/associations/join_dependency/join_association.rb +0 -15
  113. data/lib/torque/postgresql/schema_dumper.rb +0 -91
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: 1.1.7
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,48 +16,48 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.18'
33
+ version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.18'
40
+ version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.1'
47
+ version: '12.3'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 10.1.0
50
+ version: 12.3.3
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '10.1'
57
+ version: '12.3'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 10.1.0
60
+ version: 12.3.3
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: database_cleaner
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +201,6 @@ files:
201
201
  - lib/torque/postgresql/associations/builder.rb
202
202
  - lib/torque/postgresql/associations/builder/belongs_to_many.rb
203
203
  - lib/torque/postgresql/associations/builder/has_many.rb
204
- - lib/torque/postgresql/associations/join_dependency/join_association.rb
205
204
  - lib/torque/postgresql/associations/preloader.rb
206
205
  - lib/torque/postgresql/associations/preloader/association.rb
207
206
  - lib/torque/postgresql/attributes.rb
@@ -238,9 +237,53 @@ files:
238
237
  - lib/torque/postgresql/relation/inheritance.rb
239
238
  - lib/torque/postgresql/relation/merger.rb
240
239
  - lib/torque/postgresql/schema_cache.rb
241
- - lib/torque/postgresql/schema_dumper.rb
242
240
  - lib/torque/postgresql/version.rb
243
241
  - lib/torque/range.rb
242
+ - spec/en.yml
243
+ - spec/factories/authors.rb
244
+ - spec/factories/comments.rb
245
+ - spec/factories/posts.rb
246
+ - spec/factories/tags.rb
247
+ - spec/factories/texts.rb
248
+ - spec/factories/users.rb
249
+ - spec/factories/videos.rb
250
+ - spec/mocks/cache_query.rb
251
+ - spec/mocks/create_table.rb
252
+ - spec/models/activity.rb
253
+ - spec/models/activity_book.rb
254
+ - spec/models/activity_post.rb
255
+ - spec/models/activity_post/sample.rb
256
+ - spec/models/author.rb
257
+ - spec/models/author_journalist.rb
258
+ - spec/models/comment.rb
259
+ - spec/models/course.rb
260
+ - spec/models/geometry.rb
261
+ - spec/models/guest_comment.rb
262
+ - spec/models/post.rb
263
+ - spec/models/tag.rb
264
+ - spec/models/text.rb
265
+ - spec/models/time_keeper.rb
266
+ - spec/models/user.rb
267
+ - spec/models/video.rb
268
+ - spec/schema.rb
269
+ - spec/spec_helper.rb
270
+ - spec/tests/arel_spec.rb
271
+ - spec/tests/auxiliary_statement_spec.rb
272
+ - spec/tests/belongs_to_many_spec.rb
273
+ - spec/tests/coder_spec.rb
274
+ - spec/tests/collector_spec.rb
275
+ - spec/tests/distinct_on_spec.rb
276
+ - spec/tests/enum_set_spec.rb
277
+ - spec/tests/enum_spec.rb
278
+ - spec/tests/geometric_builder_spec.rb
279
+ - spec/tests/has_many_spec.rb
280
+ - spec/tests/interval_spec.rb
281
+ - spec/tests/lazy_spec.rb
282
+ - spec/tests/period_spec.rb
283
+ - spec/tests/quoting_spec.rb
284
+ - spec/tests/range_spec.rb
285
+ - spec/tests/relation_spec.rb
286
+ - spec/tests/table_inheritance_spec.rb
244
287
  homepage: https://github.com/crashtech/torque-postgresql
245
288
  licenses:
246
289
  - MIT
@@ -253,7 +296,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
296
  requirements:
254
297
  - - ">="
255
298
  - !ruby/object:Gem::Version
256
- version: 2.2.2
299
+ version: 2.5.0
257
300
  required_rubygems_version: !ruby/object:Gem::Requirement
258
301
  requirements:
259
302
  - - ">="
@@ -264,4 +307,49 @@ rubygems_version: 3.1.4
264
307
  signing_key:
265
308
  specification_version: 4
266
309
  summary: ActiveRecord extension to access PostgreSQL advanced resources
267
- test_files: []
310
+ test_files:
311
+ - spec/models/activity_post/sample.rb
312
+ - spec/models/activity.rb
313
+ - spec/models/author.rb
314
+ - spec/models/author_journalist.rb
315
+ - spec/models/comment.rb
316
+ - spec/models/course.rb
317
+ - spec/models/post.rb
318
+ - spec/models/text.rb
319
+ - spec/models/user.rb
320
+ - spec/models/activity_book.rb
321
+ - spec/models/activity_post.rb
322
+ - spec/models/geometry.rb
323
+ - spec/models/guest_comment.rb
324
+ - spec/models/tag.rb
325
+ - spec/models/time_keeper.rb
326
+ - spec/models/video.rb
327
+ - spec/factories/authors.rb
328
+ - spec/factories/comments.rb
329
+ - spec/factories/posts.rb
330
+ - spec/factories/tags.rb
331
+ - spec/factories/texts.rb
332
+ - spec/factories/users.rb
333
+ - spec/factories/videos.rb
334
+ - spec/tests/geometric_builder_spec.rb
335
+ - spec/tests/range_spec.rb
336
+ - spec/tests/table_inheritance_spec.rb
337
+ - spec/tests/enum_spec.rb
338
+ - spec/tests/auxiliary_statement_spec.rb
339
+ - spec/tests/enum_set_spec.rb
340
+ - spec/tests/coder_spec.rb
341
+ - spec/tests/collector_spec.rb
342
+ - spec/tests/distinct_on_spec.rb
343
+ - spec/tests/interval_spec.rb
344
+ - spec/tests/lazy_spec.rb
345
+ - spec/tests/quoting_spec.rb
346
+ - spec/tests/relation_spec.rb
347
+ - spec/tests/belongs_to_many_spec.rb
348
+ - spec/tests/period_spec.rb
349
+ - spec/tests/arel_spec.rb
350
+ - spec/tests/has_many_spec.rb
351
+ - spec/mocks/cache_query.rb
352
+ - spec/mocks/create_table.rb
353
+ - spec/en.yml
354
+ - spec/spec_helper.rb
355
+ - spec/schema.rb
@@ -1,15 +0,0 @@
1
- module Torque
2
- module PostgreSQL
3
- module Associations
4
- module JoinDependency
5
- module JoinAssociation
6
- def build_constraint(_, table, _, foreign_table, _)
7
- reflection.build_join_constraint(table, foreign_table)
8
- end
9
- end
10
-
11
- ::ActiveRecord::Associations::JoinDependency::JoinAssociation.prepend(JoinAssociation)
12
- end
13
- end
14
- end
15
- end
@@ -1,91 +0,0 @@
1
- module Torque
2
- module PostgreSQL
3
- module SchemaDumper
4
-
5
- include Adapter::ColumnDumper if Torque::PostgreSQL::AR521
6
-
7
- def dump(stream) # :nodoc:
8
- @connection.dump_mode!
9
- super
10
-
11
- @connection.dump_mode!
12
- stream
13
- end
14
-
15
- def extensions(stream) # :nodoc:
16
- super
17
- user_defined_types(stream)
18
- end
19
-
20
- private
21
-
22
- def tables(stream) # :nodoc:
23
- inherited_tables = @connection.inherited_tables
24
- sorted_tables = @connection.data_sources.sort - @connection.views
25
-
26
- stream.puts " # These are the common tables managed"
27
- (sorted_tables - inherited_tables.keys).each do |table_name|
28
- table(table_name, stream) unless ignored?(table_name)
29
- end
30
-
31
- if inherited_tables.present?
32
- stream.puts " # These are tables that has inheritance"
33
- inherited_tables.each do |table_name, inherits|
34
- next if ignored?(table_name)
35
-
36
- sub_stream = StringIO.new
37
- table(table_name, sub_stream)
38
-
39
- # Add the inherits setting
40
- sub_stream.rewind
41
- inherits.map!(&:to_sym)
42
- inherits = inherits.first if inherits.size === 1
43
- inherits = ", inherits: #{inherits.inspect} do |t|"
44
- table_dump = sub_stream.read.gsub(/ do \|t\|$/, inherits)
45
-
46
- # Ensure bodyless definitions
47
- table_dump.gsub!(/do \|t\|\n end/, '')
48
- stream.print table_dump
49
- end
50
- end
51
-
52
- # dump foreign keys at the end to make sure all dependent tables exist.
53
- if @connection.supports_foreign_keys?
54
- sorted_tables.each do |tbl|
55
- foreign_keys(tbl, stream) unless ignored?(tbl)
56
- end
57
- end
58
-
59
- # Scenic integration
60
- views(stream) if defined?(::Scenic)
61
- end
62
-
63
- # Dump user defined types like enum
64
- def user_defined_types(stream)
65
- types = @connection.user_defined_types('e')
66
- return unless types.any?
67
-
68
- stream.puts " # These are user-defined types used on this database"
69
- types.sort_by(&:first).each { |name, type| send(type.to_sym, name, stream) }
70
- stream.puts
71
- rescue => e
72
- stream.puts "# Could not dump user-defined types because of following #{e.class}"
73
- stream.puts "# #{e.message}"
74
- stream.puts
75
- end
76
-
77
- # Dump enum custom type
78
- def enum(name, stream)
79
- values = @connection.enum_values(name).map { |v| "\"#{v}\"" }
80
- stream.puts " create_enum \"#{name}\", [#{values.join(', ')}], force: :cascade"
81
- end
82
-
83
- end
84
-
85
- if Torque::PostgreSQL::AR521
86
- ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend SchemaDumper
87
- else
88
- ActiveRecord::SchemaDumper.prepend SchemaDumper
89
- end
90
- end
91
- end