torque-postgresql 1.1.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/torque/postgresql.rb +0 -2
- data/lib/torque/postgresql/adapter.rb +0 -1
- data/lib/torque/postgresql/adapter/database_statements.rb +4 -15
- data/lib/torque/postgresql/adapter/schema_creation.rb +13 -23
- data/lib/torque/postgresql/adapter/schema_definitions.rb +7 -21
- data/lib/torque/postgresql/adapter/schema_dumper.rb +71 -11
- data/lib/torque/postgresql/adapter/schema_statements.rb +2 -12
- data/lib/torque/postgresql/associations.rb +0 -3
- data/lib/torque/postgresql/associations/association_scope.rb +18 -60
- data/lib/torque/postgresql/associations/belongs_to_many_association.rb +12 -15
- data/lib/torque/postgresql/associations/preloader.rb +0 -32
- data/lib/torque/postgresql/associations/preloader/association.rb +13 -9
- data/lib/torque/postgresql/autosave_association.rb +4 -4
- data/lib/torque/postgresql/auxiliary_statement.rb +1 -13
- data/lib/torque/postgresql/coder.rb +1 -2
- data/lib/torque/postgresql/config.rb +0 -6
- data/lib/torque/postgresql/inheritance.rb +13 -17
- data/lib/torque/postgresql/reflection/abstract_reflection.rb +19 -25
- data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +4 -38
- data/lib/torque/postgresql/relation.rb +11 -16
- data/lib/torque/postgresql/relation/auxiliary_statement.rb +2 -8
- data/lib/torque/postgresql/relation/distinct_on.rb +1 -1
- data/lib/torque/postgresql/version.rb +1 -1
- data/spec/en.yml +19 -0
- data/spec/factories/authors.rb +6 -0
- data/spec/factories/comments.rb +13 -0
- data/spec/factories/posts.rb +6 -0
- data/spec/factories/tags.rb +5 -0
- data/spec/factories/texts.rb +5 -0
- data/spec/factories/users.rb +6 -0
- data/spec/factories/videos.rb +5 -0
- data/spec/mocks/cache_query.rb +16 -0
- data/spec/mocks/create_table.rb +35 -0
- data/spec/models/activity.rb +3 -0
- data/spec/models/activity_book.rb +4 -0
- data/spec/models/activity_post.rb +7 -0
- data/spec/models/activity_post/sample.rb +4 -0
- data/spec/models/author.rb +4 -0
- data/spec/models/author_journalist.rb +4 -0
- data/spec/models/comment.rb +3 -0
- data/spec/models/course.rb +2 -0
- data/spec/models/geometry.rb +2 -0
- data/spec/models/guest_comment.rb +4 -0
- data/spec/models/post.rb +6 -0
- data/spec/models/tag.rb +2 -0
- data/spec/models/text.rb +2 -0
- data/spec/models/time_keeper.rb +2 -0
- data/spec/models/user.rb +8 -0
- data/spec/models/video.rb +2 -0
- data/spec/schema.rb +141 -0
- data/spec/spec_helper.rb +59 -0
- data/spec/tests/arel_spec.rb +72 -0
- data/spec/tests/auxiliary_statement_spec.rb +593 -0
- data/spec/tests/belongs_to_many_spec.rb +240 -0
- data/spec/tests/coder_spec.rb +367 -0
- data/spec/tests/collector_spec.rb +59 -0
- data/spec/tests/distinct_on_spec.rb +65 -0
- data/spec/tests/enum_set_spec.rb +306 -0
- data/spec/tests/enum_spec.rb +621 -0
- data/spec/tests/geometric_builder_spec.rb +221 -0
- data/spec/tests/has_many_spec.rb +390 -0
- data/spec/tests/interval_spec.rb +167 -0
- data/spec/tests/lazy_spec.rb +24 -0
- data/spec/tests/period_spec.rb +954 -0
- data/spec/tests/quoting_spec.rb +24 -0
- data/spec/tests/range_spec.rb +36 -0
- data/spec/tests/relation_spec.rb +57 -0
- data/spec/tests/table_inheritance_spec.rb +403 -0
- metadata +103 -15
- data/lib/torque/postgresql/associations/join_dependency/join_association.rb +0 -15
- 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:
|
4
|
+
version: 2.0.0
|
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-
|
11
|
+
date: 2020-05-23 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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
47
|
+
version: '12.3'
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
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: '
|
57
|
+
version: '12.3'
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
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,15 +296,60 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
296
|
requirements:
|
254
297
|
- - ">="
|
255
298
|
- !ruby/object:Gem::Version
|
256
|
-
version: 2.
|
299
|
+
version: 2.5.0
|
257
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
301
|
requirements:
|
259
302
|
- - ">="
|
260
303
|
- !ruby/object:Gem::Version
|
261
304
|
version: 1.8.11
|
262
305
|
requirements: []
|
263
|
-
rubygems_version: 3.1.
|
306
|
+
rubygems_version: 3.1.2
|
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/auxiliary_statement_spec.rb
|
337
|
+
- spec/tests/belongs_to_many_spec.rb
|
338
|
+
- spec/tests/has_many_spec.rb
|
339
|
+
- spec/tests/period_spec.rb
|
340
|
+
- spec/tests/table_inheritance_spec.rb
|
341
|
+
- spec/tests/coder_spec.rb
|
342
|
+
- spec/tests/collector_spec.rb
|
343
|
+
- spec/tests/distinct_on_spec.rb
|
344
|
+
- spec/tests/interval_spec.rb
|
345
|
+
- spec/tests/lazy_spec.rb
|
346
|
+
- spec/tests/quoting_spec.rb
|
347
|
+
- spec/tests/relation_spec.rb
|
348
|
+
- spec/tests/arel_spec.rb
|
349
|
+
- spec/tests/enum_set_spec.rb
|
350
|
+
- spec/tests/enum_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
|