torque-postgresql 2.0.1 → 2.0.6
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/adapter.rb +7 -0
- data/lib/torque/postgresql/adapter/database_statements.rb +2 -0
- data/lib/torque/postgresql/adapter/oid.rb +3 -1
- data/lib/torque/postgresql/adapter/oid/box.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/circle.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/enum.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/enum_set.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/interval.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/line.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/range.rb +2 -0
- data/lib/torque/postgresql/adapter/oid/segment.rb +2 -0
- data/lib/torque/postgresql/adapter/quoting.rb +2 -0
- data/lib/torque/postgresql/adapter/schema_creation.rb +8 -1
- data/lib/torque/postgresql/adapter/schema_definitions.rb +2 -0
- data/lib/torque/postgresql/adapter/schema_dumper.rb +11 -2
- data/lib/torque/postgresql/adapter/schema_statements.rb +2 -0
- data/lib/torque/postgresql/arel/infix_operation.rb +5 -1
- data/lib/torque/postgresql/arel/join_source.rb +2 -0
- data/lib/torque/postgresql/arel/nodes.rb +2 -0
- data/lib/torque/postgresql/arel/operations.rb +2 -0
- data/lib/torque/postgresql/arel/select_manager.rb +2 -0
- data/lib/torque/postgresql/arel/visitors.rb +6 -3
- data/lib/torque/postgresql/associations/association.rb +14 -3
- data/lib/torque/postgresql/associations/association_scope.rb +2 -0
- data/lib/torque/postgresql/associations/belongs_to_many_association.rb +164 -47
- data/lib/torque/postgresql/associations/builder/belongs_to_many.rb +8 -5
- data/lib/torque/postgresql/associations/builder/has_many.rb +2 -0
- data/lib/torque/postgresql/associations/preloader/association.rb +30 -1
- data/lib/torque/postgresql/attributes/builder.rb +3 -1
- data/lib/torque/postgresql/attributes/builder/enum.rb +5 -3
- data/lib/torque/postgresql/attributes/builder/period.rb +6 -4
- data/lib/torque/postgresql/attributes/enum.rb +5 -10
- data/lib/torque/postgresql/attributes/enum_set.rb +2 -0
- data/lib/torque/postgresql/attributes/lazy.rb +3 -1
- data/lib/torque/postgresql/attributes/period.rb +2 -0
- data/lib/torque/postgresql/autosave_association.rb +19 -16
- data/lib/torque/postgresql/auxiliary_statement.rb +2 -0
- data/lib/torque/postgresql/auxiliary_statement/settings.rb +2 -0
- data/lib/torque/postgresql/base.rb +5 -2
- data/lib/torque/postgresql/coder.rb +5 -3
- data/lib/torque/postgresql/collector.rb +2 -0
- data/lib/torque/postgresql/config.rb +5 -0
- data/lib/torque/postgresql/geometry_builder.rb +2 -0
- data/lib/torque/postgresql/i18n.rb +2 -0
- data/lib/torque/postgresql/inheritance.rb +2 -0
- data/lib/torque/postgresql/migration/command_recorder.rb +2 -0
- data/lib/torque/postgresql/railtie.rb +2 -0
- data/lib/torque/postgresql/reflection.rb +2 -0
- data/lib/torque/postgresql/reflection/abstract_reflection.rb +13 -28
- data/lib/torque/postgresql/reflection/association_reflection.rb +24 -0
- data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +18 -4
- data/lib/torque/postgresql/reflection/has_many_reflection.rb +2 -0
- data/lib/torque/postgresql/reflection/runtime_reflection.rb +2 -0
- data/lib/torque/postgresql/reflection/through_reflection.rb +2 -0
- data/lib/torque/postgresql/relation.rb +15 -11
- data/lib/torque/postgresql/relation/auxiliary_statement.rb +6 -1
- data/lib/torque/postgresql/relation/distinct_on.rb +2 -0
- data/lib/torque/postgresql/relation/inheritance.rb +2 -0
- data/lib/torque/postgresql/relation/merger.rb +2 -0
- data/lib/torque/postgresql/schema_cache.rb +2 -0
- data/lib/torque/postgresql/version.rb +3 -1
- data/spec/schema.rb +3 -2
- data/spec/tests/arel_spec.rb +3 -1
- data/spec/tests/belongs_to_many_spec.rb +104 -12
- data/spec/tests/enum_set_spec.rb +1 -1
- data/spec/tests/has_many_spec.rb +25 -1
- data/spec/tests/table_inheritance_spec.rb +1 -1
- metadata +7 -7
data/spec/tests/enum_set_spec.rb
CHANGED
@@ -48,7 +48,7 @@ RSpec.describe 'Enum' do
|
|
48
48
|
expect(dump_io.string).to match checker
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
xit 'can have a default value as an array of symbols' do
|
52
52
|
dump_io = StringIO.new
|
53
53
|
checker = /t\.enum +"types", +default: \[:A, :B\], +array: true, +subtype: :types/
|
54
54
|
ActiveRecord::SchemaDumper.dump(connection, dump_io)
|
data/spec/tests/has_many_spec.rb
CHANGED
@@ -5,7 +5,7 @@ RSpec.describe 'HasMany' do
|
|
5
5
|
let(:builder) { ActiveRecord::Associations::Builder::HasMany }
|
6
6
|
|
7
7
|
it 'adds the array option' do
|
8
|
-
expect(builder.send(:valid_options,
|
8
|
+
expect(builder.send(:valid_options, {})).to include(:array)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -21,6 +21,11 @@ RSpec.describe 'HasMany' do
|
|
21
21
|
expect(subject._reflections).to include('texts')
|
22
22
|
end
|
23
23
|
|
24
|
+
it 'has correct foreign key' do
|
25
|
+
item = subject._reflections['texts']
|
26
|
+
expect(item.foreign_key).to be_eql('user_id')
|
27
|
+
end
|
28
|
+
|
24
29
|
it 'loads associated records' do
|
25
30
|
expect(subject.texts.to_sql).to match(Regexp.new(<<-SQL.squish))
|
26
31
|
SELECT "texts"\\.\\* FROM "texts" WHERE \\(?"texts"\\."user_id" = #{subject.id}\\)?
|
@@ -210,6 +215,11 @@ RSpec.describe 'HasMany' do
|
|
210
215
|
expect(subject._reflections).to include('videos')
|
211
216
|
end
|
212
217
|
|
218
|
+
it 'has correct foreign key' do
|
219
|
+
item = subject._reflections['videos']
|
220
|
+
expect(item.foreign_key).to be_eql('tag_ids')
|
221
|
+
end
|
222
|
+
|
213
223
|
it 'loads associated records' do
|
214
224
|
expect(subject.videos.to_sql).to match(Regexp.new(<<-SQL.squish))
|
215
225
|
SELECT "videos"\\.\\* FROM "videos"
|
@@ -281,6 +291,20 @@ RSpec.describe 'HasMany' do
|
|
281
291
|
expect(record.tag_ids).to be_eql([subject.id])
|
282
292
|
end
|
283
293
|
|
294
|
+
it 'can perist after accessed in after_create' do
|
295
|
+
other.belongs_to_many(:tags)
|
296
|
+
other.after_create { self.tags.to_a }
|
297
|
+
|
298
|
+
video = FactoryBot.create(:video)
|
299
|
+
subject.videos << video
|
300
|
+
|
301
|
+
expect(subject.reload.videos.size).to eql(1)
|
302
|
+
expect(video.reload.tags.size).to eql(1)
|
303
|
+
|
304
|
+
other.reset_callbacks(:create)
|
305
|
+
other._reflections = {}
|
306
|
+
end
|
307
|
+
|
284
308
|
it 'can concat records' do
|
285
309
|
FactoryBot.create(:video, tag_ids: [subject.id])
|
286
310
|
expect(subject.videos.size).to be_eql(1)
|
@@ -66,7 +66,7 @@ RSpec.describe 'TableInheritance' do
|
|
66
66
|
|
67
67
|
it 'allows empty-body create table operation' do
|
68
68
|
sql = connection.create_table(:activity_posts, inherits: :activities)
|
69
|
-
result =
|
69
|
+
result = "CREATE TABLE \"activity_posts\" ()"
|
70
70
|
result << ' INHERITS ( "activities" )'
|
71
71
|
expect(sql).to eql(result)
|
72
72
|
end
|
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.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -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/arel_spec.rb
|
336
337
|
- spec/tests/enum_spec.rb
|
337
|
-
- spec/tests/
|
338
|
-
- spec/tests/has_many_spec.rb
|
339
|
-
- spec/tests/table_inheritance_spec.rb
|
338
|
+
- spec/tests/period_spec.rb
|
340
339
|
- spec/tests/coder_spec.rb
|
341
340
|
- spec/tests/collector_spec.rb
|
342
341
|
- spec/tests/distinct_on_spec.rb
|
@@ -344,10 +343,11 @@ test_files:
|
|
344
343
|
- spec/tests/lazy_spec.rb
|
345
344
|
- spec/tests/quoting_spec.rb
|
346
345
|
- spec/tests/relation_spec.rb
|
347
|
-
- spec/tests/
|
346
|
+
- spec/tests/auxiliary_statement_spec.rb
|
348
347
|
- spec/tests/enum_set_spec.rb
|
348
|
+
- spec/tests/has_many_spec.rb
|
349
349
|
- spec/tests/belongs_to_many_spec.rb
|
350
|
-
- spec/tests/
|
350
|
+
- spec/tests/table_inheritance_spec.rb
|
351
351
|
- spec/mocks/cache_query.rb
|
352
352
|
- spec/mocks/create_table.rb
|
353
353
|
- spec/en.yml
|