torque-postgresql 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5076bbdf3cee649de6955a308c0a51425755f5c87a2e83ee4b028a5009f6960f
4
- data.tar.gz: ba7308a8927428a6496ef04b9edbd09270c303d43d0d10a9528033734a86fe2f
3
+ metadata.gz: 4164165e64b027d11997dde286684b27bd77c33634e3eb84c6f1c757b5d814a0
4
+ data.tar.gz: 8bf196d92b261661631ceb02f2ab7600a8a6cec5cacc43fa69b0c300afb65582
5
5
  SHA512:
6
- metadata.gz: 4898d7f63ec4a7df180d3c4dcb80aab3d7269bcede0eab54a03f0c3591d314ddc025e45f755a9ae60a914d6cc4ecc8ca42011c44afbb62ec3432693a1abf8be0
7
- data.tar.gz: a4621ea2a37aa566fcb33db4cdcaaf83b4539d96ed30628f81fda79f0b02c2c2ab1b197ef6e0448cbcdc43b584e53293ca110f3d299a0c6b13b89ff4f34aefcb
6
+ metadata.gz: 7e44fd4215ba1ef9d2aebf8d6a5c285266f0bb64544a2a74d36773aaaa8e57c5776c3260183352accf76f81e94edcba27ffa898145e4d0bb467f5097ce7e7467
7
+ data.tar.gz: 9c8acb15a0e78f33e8da372dcffc0e1a3e238631d01932056e5e48392801ec3706c3168a138944e5ebe7b80222f2f962e32af043a91c29235b6e824e02b70bbc
@@ -49,21 +49,21 @@ module Torque
49
49
  if inherited_tables.present?
50
50
  stream.puts " # These are tables that has inheritance"
51
51
  inherited_tables.each do |table_name, inherits|
52
- unless ignored?(table_name)
53
- sub_stream = StringIO.new
54
- table(table_name, sub_stream)
55
-
56
- # Add the inherits setting
57
- sub_stream.rewind
58
- inherits.map!(&:to_sym)
59
- inherits = inherits.first if inherits.size === 1
60
- inherits = ", inherits: #{inherits.inspect} do |t|"
61
- table_dump = sub_stream.read.gsub(/ do \|t\|$/, inherits)
62
-
63
- # Ensure bodyless definitions
64
- table_dump.gsub!(/do \|t\|\n end/, '')
65
- stream.print table_dump
66
- end
52
+ next if ignored?(table_name)
53
+
54
+ sub_stream = StringIO.new
55
+ table(table_name, sub_stream)
56
+
57
+ # Add the inherits setting
58
+ sub_stream.rewind
59
+ inherits.map!(&:to_sym)
60
+ inherits = inherits.first if inherits.size === 1
61
+ inherits = ", inherits: #{inherits.inspect} do |t|"
62
+ table_dump = sub_stream.read.gsub(/ do \|t\|$/, inherits)
63
+
64
+ # Ensure bodyless definitions
65
+ table_dump.gsub!(/do \|t\|\n end/, '')
66
+ stream.print table_dump
67
67
  end
68
68
  end
69
69
 
@@ -81,7 +81,7 @@ module Torque
81
81
  return unless types.any?
82
82
 
83
83
  stream.puts " # These are user-defined types used on this database"
84
- types.each { |name, type| send(type.to_sym, name, stream) }
84
+ types.sort_by(&:first).each { |(name, type)| send(type.to_sym, name, stream) }
85
85
  stream.puts
86
86
  rescue => e
87
87
  stream.puts "# Could not dump user-defined types because of following #{e.class}"
@@ -1,5 +1,5 @@
1
1
  module Torque
2
2
  module PostgreSQL
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -124,6 +124,13 @@ RSpec.describe 'Enum' do
124
124
  expect(dump_io.string).to match /create_enum \"content_status\", \[/
125
125
  end
126
126
 
127
+ it 'sorts the enum entries to better consistency' do
128
+ dump_io = StringIO.new
129
+ ActiveRecord::SchemaDumper.dump(connection, dump_io)
130
+ items = dump_io.string.scan(/create_enum "(\w+)"/).flatten
131
+ expect(items).to be_eql(items.sort)
132
+ end
133
+
127
134
  it 'do not dump when has none' do
128
135
  connection.drop_type(:content_status, force: :cascade)
129
136
 
@@ -231,6 +231,19 @@ RSpec.describe 'TableInheritance' do
231
231
  expect(child2.table_name).to eql('activity_books')
232
232
  expect(other.table_name).to eql('authors')
233
233
  end
234
+
235
+ it 'respects the table name prefix and sufix defined on parent module' do
236
+ mod = Object.const_set('Private', Module.new)
237
+ mod.define_singleton_method(:table_name_prefix) { 'private.' }
238
+ mod.define_singleton_method(:table_name_suffix) { '_bundle' }
239
+ result = 'private.activity_post_others_bundle'
240
+
241
+ klass = mod.const_set('Other', Class.new(ActivityPost))
242
+ allow(klass).to receive(:module_parent).and_return(child)
243
+ allow(klass).to receive(:module_parents).and_return([mod])
244
+ allow(klass).to receive(:physically_inherited?).and_return(true)
245
+ expect(klass.send(:compute_table_name)).to be_eql(result)
246
+ end
234
247
  end
235
248
 
236
249
  context 'on relation' do
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.0.0
4
+ version: 2.0.1
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-05-23 00:00:00.000000000 Z
11
+ date: 2020-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
303
  - !ruby/object:Gem::Version
304
304
  version: 1.8.11
305
305
  requirements: []
306
- rubygems_version: 3.1.2
306
+ rubygems_version: 3.1.4
307
307
  signing_key:
308
308
  specification_version: 4
309
309
  summary: ActiveRecord extension to access PostgreSQL advanced resources
@@ -333,10 +333,9 @@ test_files:
333
333
  - spec/factories/videos.rb
334
334
  - spec/tests/geometric_builder_spec.rb
335
335
  - spec/tests/range_spec.rb
336
+ - spec/tests/enum_spec.rb
336
337
  - spec/tests/auxiliary_statement_spec.rb
337
- - spec/tests/belongs_to_many_spec.rb
338
338
  - spec/tests/has_many_spec.rb
339
- - spec/tests/period_spec.rb
340
339
  - spec/tests/table_inheritance_spec.rb
341
340
  - spec/tests/coder_spec.rb
342
341
  - spec/tests/collector_spec.rb
@@ -347,7 +346,8 @@ test_files:
347
346
  - spec/tests/relation_spec.rb
348
347
  - spec/tests/arel_spec.rb
349
348
  - spec/tests/enum_set_spec.rb
350
- - spec/tests/enum_spec.rb
349
+ - spec/tests/belongs_to_many_spec.rb
350
+ - spec/tests/period_spec.rb
351
351
  - spec/mocks/cache_query.rb
352
352
  - spec/mocks/create_table.rb
353
353
  - spec/en.yml