torque-postgresql 3.3.3 → 3.4.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 +4 -4
- data/lib/torque/postgresql/arel/visitors.rb +1 -1
- data/lib/torque/postgresql/associations/preloader/loader_query.rb +1 -1
- data/lib/torque/postgresql/base.rb +5 -3
- data/lib/torque/postgresql/config.rb +1 -0
- data/lib/torque/postgresql/relation.rb +9 -1
- data/lib/torque/postgresql/schema_cache/bound_schema_reflection.rb +8 -4
- data/lib/torque/postgresql/schema_cache/schema_reflection.rb +8 -8
- data/lib/torque/postgresql/schema_cache.rb +17 -12
- data/lib/torque/postgresql/version.rb +1 -1
- data/spec/mocks/cache_query.rb +25 -8
- data/spec/schema.rb +2 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/tests/arel_spec.rb +5 -0
- data/spec/tests/auxiliary_statement_spec.rb +2 -2
- data/spec/tests/belongs_to_many_spec.rb +6 -3
- data/spec/tests/enum_set_spec.rb +9 -1
- data/spec/tests/has_many_spec.rb +6 -4
- data/spec/tests/interval_spec.rb +9 -2
- data/spec/tests/schema_spec.rb +8 -1
- data/spec/tests/table_inheritance_spec.rb +18 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c61aaf577483288d5c9a9af30704402529c86318cbdc312f567b643955c1443e
|
4
|
+
data.tar.gz: ccb9930f10cd48eb08448ecd99275fd7ca7ef54443fab81476c6b3a57c03e394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ed5cb4bb34b33de90020a7053378378b28ff0f45cc7a33e53084fa86c9069ab7694890fa0cac1ab19a85f5ee825cc317d3406cf8f98d4336ff416a2bae092b
|
7
|
+
data.tar.gz: 22771a0e4b1ce1486ae0ae6700c81cbbf84b227bb78b1a7163be2d2948b7161e822bb32dfdcc399c103348e2ab89f8cdda04112f988d303fd0735e178a605043
|
@@ -25,7 +25,7 @@ module Torque
|
|
25
25
|
|
26
26
|
# Allow quoted arrays to get here
|
27
27
|
def visit_Arel_Nodes_Casted(o, collector)
|
28
|
-
value = o.
|
28
|
+
value = o.value_for_database
|
29
29
|
return super unless value.is_a?(::Enumerable)
|
30
30
|
quote_array(value, collector)
|
31
31
|
end
|
@@ -201,9 +201,11 @@ module Torque
|
|
201
201
|
end
|
202
202
|
|
203
203
|
# Allow extra keyword arguments to be sent to +InsertAll+
|
204
|
-
|
205
|
-
|
206
|
-
|
204
|
+
unless Torque::PostgreSQL::AR720
|
205
|
+
def upsert_all(attributes, **xargs)
|
206
|
+
xargs = xargs.reverse_merge(on_duplicate: :update)
|
207
|
+
::ActiveRecord::InsertAll.new(self, attributes, **xargs).execute
|
208
|
+
end
|
207
209
|
end
|
208
210
|
|
209
211
|
protected
|
@@ -6,6 +6,7 @@ module Torque
|
|
6
6
|
|
7
7
|
# Stores a version check for compatibility purposes
|
8
8
|
AR710 = (ActiveRecord.gem_version >= Gem::Version.new('7.1.0'))
|
9
|
+
AR720 = (ActiveRecord.gem_version >= Gem::Version.new('7.2.0'))
|
9
10
|
|
10
11
|
# Use the same logger as the Active Record one
|
11
12
|
def self.logger
|
@@ -102,7 +102,7 @@ module Torque
|
|
102
102
|
# Compatibility method with 5.0
|
103
103
|
unless ActiveRecord::Relation.method_defined?(:set_value)
|
104
104
|
def set_value(name, value)
|
105
|
-
assert_mutability!
|
105
|
+
assert_mutability! if respond_to?(:assert_mutability!)
|
106
106
|
@values[name] = value
|
107
107
|
end
|
108
108
|
end
|
@@ -133,6 +133,14 @@ module Torque
|
|
133
133
|
klass.superclass.send(:relation) if klass.define_attribute_methods &&
|
134
134
|
klass.superclass != ActiveRecord::Base && !klass.superclass.abstract_class?
|
135
135
|
end
|
136
|
+
|
137
|
+
# Allow extra keyword arguments to be sent to +InsertAll+
|
138
|
+
if Torque::PostgreSQL::AR720
|
139
|
+
def upsert_all(attributes, **xargs)
|
140
|
+
xargs = xargs.reverse_merge(on_duplicate: :update)
|
141
|
+
::ActiveRecord::InsertAll.execute(self, attributes, **xargs)
|
142
|
+
end
|
143
|
+
end
|
136
144
|
end
|
137
145
|
end
|
138
146
|
|
@@ -4,19 +4,23 @@ module Torque
|
|
4
4
|
module PostgreSQL
|
5
5
|
module BoundSchemaReflection
|
6
6
|
def add_model_name(table_name, model)
|
7
|
-
|
7
|
+
source = defined?(@pool) ? @pool : @connection
|
8
|
+
@schema_reflection.add_model_name(source, table_name, model)
|
8
9
|
end
|
9
10
|
|
10
11
|
def dependencies(table_name)
|
11
|
-
|
12
|
+
source = defined?(@pool) ? @pool : @connection
|
13
|
+
@schema_reflection.dependencies(source, table_name)
|
12
14
|
end
|
13
15
|
|
14
16
|
def associations(table_name)
|
15
|
-
|
17
|
+
source = defined?(@pool) ? @pool : @connection
|
18
|
+
@schema_reflection.associations(source, table_name)
|
16
19
|
end
|
17
20
|
|
18
21
|
def lookup_model(table_name, scoped_class = '')
|
19
|
-
|
22
|
+
source = defined?(@pool) ? @pool : @connection
|
23
|
+
@schema_reflection.lookup_model(source, table_name, scoped_class)
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -3,20 +3,20 @@
|
|
3
3
|
module Torque
|
4
4
|
module PostgreSQL
|
5
5
|
module SchemaReflection
|
6
|
-
def add_model_name(
|
7
|
-
cache(
|
6
|
+
def add_model_name(source, table_name, model)
|
7
|
+
cache(source).add_model_name(source, table_name, model)
|
8
8
|
end
|
9
9
|
|
10
|
-
def dependencies(
|
11
|
-
cache(
|
10
|
+
def dependencies(source, table_name)
|
11
|
+
cache(source).dependencies(source, table_name)
|
12
12
|
end
|
13
13
|
|
14
|
-
def associations(
|
15
|
-
cache(
|
14
|
+
def associations(source, table_name)
|
15
|
+
cache(source).associations(source, table_name)
|
16
16
|
end
|
17
17
|
|
18
|
-
def lookup_model(
|
19
|
-
cache(
|
18
|
+
def lookup_model(source, table_name, scoped_class)
|
19
|
+
cache(source).lookup_model(table_name, scoped_class)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -105,15 +105,15 @@ module Torque
|
|
105
105
|
end
|
106
106
|
|
107
107
|
# Get all the tables that the given one inherits from
|
108
|
-
def dependencies(
|
109
|
-
reload_inheritance_data!(
|
108
|
+
def dependencies(source, table_name = source)
|
109
|
+
reload_inheritance_data!(source == table_name ? connection : source)
|
110
110
|
@inheritance_dependencies[table_name]
|
111
111
|
end
|
112
112
|
|
113
113
|
# Get the list of all tables that are associated (direct or indirect
|
114
114
|
# inheritance) with the provided one
|
115
|
-
def associations(
|
116
|
-
reload_inheritance_data!(
|
115
|
+
def associations(source, table_name = source)
|
116
|
+
reload_inheritance_data!(source == table_name ? connection : source)
|
117
117
|
@inheritance_associations[table_name]
|
118
118
|
end
|
119
119
|
|
@@ -127,11 +127,15 @@ module Torque
|
|
127
127
|
|
128
128
|
# Reload information about tables inheritance and dependencies, uses a
|
129
129
|
# cache to not perform additional checks
|
130
|
-
def reload_inheritance_data!(
|
130
|
+
def reload_inheritance_data!(source)
|
131
131
|
return if @inheritance_loaded
|
132
|
-
|
133
|
-
|
134
|
-
|
132
|
+
|
133
|
+
method_name = Torque::PostgreSQL::AR720 ? :with_connection : :then
|
134
|
+
source.public_send(method_name) do |connection|
|
135
|
+
@inheritance_dependencies = connection.inherited_tables
|
136
|
+
@inheritance_associations = generate_associations
|
137
|
+
@inheritance_loaded = true
|
138
|
+
end
|
135
139
|
end
|
136
140
|
|
137
141
|
# Calculates the inverted dependency (association), where even indirect
|
@@ -141,11 +145,12 @@ module Torque
|
|
141
145
|
end
|
142
146
|
|
143
147
|
# Use this method to also load any irregular model name
|
144
|
-
|
145
|
-
|
148
|
+
method_name = Torque::PostgreSQL::AR720 ? :add_all : :prepare_data_sources
|
149
|
+
define_method(method_name) do |source = nil|
|
150
|
+
Torque::PostgreSQL::AR710 ? super(source) : super()
|
146
151
|
|
147
|
-
|
148
|
-
@data_sources_model_names = prepare_irregular_models(
|
152
|
+
data_sources = source.present? ? tables_to_cache(source) : @data_sources.keys
|
153
|
+
@data_sources_model_names = prepare_irregular_models(data_sources)
|
149
154
|
end
|
150
155
|
|
151
156
|
end
|
data/spec/mocks/cache_query.rb
CHANGED
@@ -1,16 +1,33 @@
|
|
1
1
|
module Mocks
|
2
2
|
module CacheQuery
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
if Torque::PostgreSQL::AR720
|
4
|
+
def get_last_executed_query(&block)
|
5
|
+
cache = ActiveRecord::Base.connection.query_cache
|
6
|
+
cache.instance_variable_set(:@enabled, true)
|
6
7
|
|
7
|
-
|
8
|
-
result = conn.query_cache.keys.first
|
8
|
+
map = cache.instance_variable_get(:@map)
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
block.call
|
11
|
+
result = map.keys.first
|
12
12
|
|
13
|
-
|
13
|
+
cache.instance_variable_set(:@enabled, false)
|
14
|
+
map.delete(result)
|
15
|
+
|
16
|
+
result
|
17
|
+
end
|
18
|
+
else
|
19
|
+
def get_last_executed_query(&block)
|
20
|
+
conn = ActiveRecord::Base.connection
|
21
|
+
conn.instance_variable_set(:@query_cache_enabled, true)
|
22
|
+
|
23
|
+
block.call
|
24
|
+
result = conn.query_cache.keys.first
|
25
|
+
|
26
|
+
conn.instance_variable_set(:@query_cache_enabled, false)
|
27
|
+
conn.instance_variable_get(:@query_cache).delete(result)
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
16
33
|
end
|
data/spec/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
version =
|
13
|
+
version = 4
|
14
14
|
|
15
15
|
return if ActiveRecord::Migrator.current_version == version
|
16
16
|
ActiveRecord::Schema.define(version: version) do
|
@@ -59,6 +59,7 @@ ActiveRecord::Schema.define(version: version) do
|
|
59
59
|
t.string "url"
|
60
60
|
t.enum "type", enum_type: :types
|
61
61
|
t.enum "conflicts", enum_type: :conflicts, array: true
|
62
|
+
t.jsonb "metadata"
|
62
63
|
t.datetime "created_at", null: false
|
63
64
|
t.datetime "updated_at", null: false
|
64
65
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -40,7 +40,7 @@ RSpec.configure do |config|
|
|
40
40
|
# Handles acton before rspec initialize
|
41
41
|
config.before(:suite) do
|
42
42
|
Torque::PostgreSQL.config.schemas.whitelist << 'internal'
|
43
|
-
ActiveSupport::Deprecation.silenced
|
43
|
+
ActiveSupport::Deprecation.try(:silenced=, true)
|
44
44
|
DatabaseCleaner.clean_with(:truncation)
|
45
45
|
end
|
46
46
|
|
data/spec/tests/arel_spec.rb
CHANGED
@@ -62,6 +62,11 @@ RSpec.describe 'Arel' do
|
|
62
62
|
it 'does not break jsonb' do
|
63
63
|
expect { connection.add_column(:authors, :profile, :jsonb, default: []) }.not_to raise_error
|
64
64
|
expect(Author.columns_hash['profile'].default).to eq('[]')
|
65
|
+
|
66
|
+
condition = Author.arel_table['profile'].is_distinct_from([])
|
67
|
+
expect(Author.where(condition).to_sql).to eq(<<~SQL.squish)
|
68
|
+
SELECT "authors".* FROM "authors" WHERE "authors"."profile" IS DISTINCT FROM '[]'
|
69
|
+
SQL
|
65
70
|
end
|
66
71
|
|
67
72
|
it 'works properly when column is an array' do
|
@@ -672,7 +672,7 @@ RSpec.describe 'AuxiliaryStatement' do
|
|
672
672
|
result << ' SELECT COUNT(*) FROM "users"'
|
673
673
|
result << ' INNER JOIN "comments" ON "comments"."user_id" = "users"."id"'
|
674
674
|
|
675
|
-
query = get_last_executed_query{ subject.with(:comments).count }
|
675
|
+
query = get_last_executed_query { subject.with(:comments).count }
|
676
676
|
expect(query).to eql(result)
|
677
677
|
end
|
678
678
|
|
@@ -687,7 +687,7 @@ RSpec.describe 'AuxiliaryStatement' do
|
|
687
687
|
result << ' SELECT SUM("comments"."value") FROM "users"'
|
688
688
|
result << ' INNER JOIN "comments" ON "comments"."user_id" = "users"."id"'
|
689
689
|
|
690
|
-
query = get_last_executed_query{ subject.with(:comments).sum(comments: :value) }
|
690
|
+
query = get_last_executed_query { subject.with(:comments).sum(comments: :value) }
|
691
691
|
expect(query).to eql(result)
|
692
692
|
end
|
693
693
|
|
@@ -5,6 +5,8 @@ RSpec.describe 'BelongsToMany' do
|
|
5
5
|
let(:model) { Video }
|
6
6
|
let(:builder) { Torque::PostgreSQL::Associations::Builder::BelongsToMany }
|
7
7
|
let(:reflection) { Torque::PostgreSQL::Reflection::BelongsToManyReflection }
|
8
|
+
let(:key) { Torque::PostgreSQL::AR720 ? :tests : 'tests' }
|
9
|
+
|
8
10
|
after { model._reflections = {} }
|
9
11
|
|
10
12
|
it 'has the builder method' do
|
@@ -24,7 +26,7 @@ RSpec.describe 'BelongsToMany' do
|
|
24
26
|
it 'allows setting up foreign key and primary_key as symbol' do
|
25
27
|
model.belongs_to_many(:tests, foreign_key: :test_ids, primary_key: :test_id)
|
26
28
|
|
27
|
-
reflection = model._reflections[
|
29
|
+
reflection = model._reflections[key]
|
28
30
|
expect(reflection.foreign_key).to be_eql('test_ids')
|
29
31
|
expect(reflection.active_record_primary_key).to be_eql('test_id')
|
30
32
|
end
|
@@ -33,6 +35,7 @@ RSpec.describe 'BelongsToMany' do
|
|
33
35
|
context 'on association' do
|
34
36
|
let(:other) { Tag }
|
35
37
|
let(:initial) { FactoryBot.create(:tag) }
|
38
|
+
let(:key) { Torque::PostgreSQL::AR720 ? :tags : 'tags' }
|
36
39
|
|
37
40
|
before { Video.belongs_to_many(:tags) }
|
38
41
|
subject { Video.create(title: 'A') }
|
@@ -44,11 +47,11 @@ RSpec.describe 'BelongsToMany' do
|
|
44
47
|
|
45
48
|
it 'has the method' do
|
46
49
|
expect(subject).to respond_to(:tags)
|
47
|
-
expect(subject._reflections).to include(
|
50
|
+
expect(subject._reflections).to include(key)
|
48
51
|
end
|
49
52
|
|
50
53
|
it 'has correct foreign key' do
|
51
|
-
item = subject._reflections[
|
54
|
+
item = subject._reflections[key]
|
52
55
|
expect(item.foreign_key).to be_eql('tag_ids')
|
53
56
|
end
|
54
57
|
|
data/spec/tests/enum_set_spec.rb
CHANGED
@@ -43,8 +43,16 @@ RSpec.describe 'Enum' do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'on schema' do
|
46
|
+
let(:source) do
|
47
|
+
if Torque::PostgreSQL::AR720
|
48
|
+
ActiveRecord::Base.connection_pool
|
49
|
+
else
|
50
|
+
ActiveRecord::Base.connection
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
46
54
|
let(:dump_result) do
|
47
|
-
ActiveRecord::SchemaDumper.dump(
|
55
|
+
ActiveRecord::SchemaDumper.dump(source, (dump_result = StringIO.new))
|
48
56
|
dump_result.string
|
49
57
|
end
|
50
58
|
|
data/spec/tests/has_many_spec.rb
CHANGED
@@ -11,6 +11,7 @@ RSpec.describe 'HasMany' do
|
|
11
11
|
|
12
12
|
context 'on original' do
|
13
13
|
let(:other) { Text }
|
14
|
+
let(:key) { Torque::PostgreSQL::AR720 ? :texts : 'texts' }
|
14
15
|
|
15
16
|
before { User.has_many :texts }
|
16
17
|
subject { User.create(name: 'User 1') }
|
@@ -18,11 +19,11 @@ RSpec.describe 'HasMany' do
|
|
18
19
|
|
19
20
|
it 'has the method' do
|
20
21
|
expect(subject).to respond_to(:texts)
|
21
|
-
expect(subject._reflections).to include(
|
22
|
+
expect(subject._reflections).to include(key)
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'has correct foreign key' do
|
25
|
-
item = subject._reflections[
|
26
|
+
item = subject._reflections[key]
|
26
27
|
expect(item.foreign_key).to be_eql('user_id')
|
27
28
|
end
|
28
29
|
|
@@ -246,6 +247,7 @@ RSpec.describe 'HasMany' do
|
|
246
247
|
|
247
248
|
context 'on array' do
|
248
249
|
let(:other) { Video }
|
250
|
+
let(:key) { Torque::PostgreSQL::AR720 ? :videos : 'videos' }
|
249
251
|
|
250
252
|
before { Tag.has_many :videos, array: true }
|
251
253
|
subject { Tag.create(name: 'A') }
|
@@ -253,11 +255,11 @@ RSpec.describe 'HasMany' do
|
|
253
255
|
|
254
256
|
it 'has the method' do
|
255
257
|
expect(subject).to respond_to(:videos)
|
256
|
-
expect(subject._reflections).to include(
|
258
|
+
expect(subject._reflections).to include(key)
|
257
259
|
end
|
258
260
|
|
259
261
|
it 'has correct foreign key' do
|
260
|
-
item = subject._reflections[
|
262
|
+
item = subject._reflections[key]
|
261
263
|
expect(item.foreign_key).to be_eql('tag_ids')
|
262
264
|
end
|
263
265
|
|
data/spec/tests/interval_spec.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe 'Interval' do
|
4
|
-
let(:connection) { ActiveRecord::Base.connection }
|
5
4
|
let(:table_definition) { ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition }
|
5
|
+
let(:connection) { ActiveRecord::Base.connection }
|
6
|
+
let(:source) do
|
7
|
+
if Torque::PostgreSQL::AR720
|
8
|
+
ActiveRecord::Base.connection_pool
|
9
|
+
else
|
10
|
+
ActiveRecord::Base.connection
|
11
|
+
end
|
12
|
+
end
|
6
13
|
|
7
14
|
context 'on settings' do
|
8
15
|
it 'must be set to ISO 8601' do
|
@@ -27,7 +34,7 @@ RSpec.describe 'Interval' do
|
|
27
34
|
context 'on schema' do
|
28
35
|
it 'can be used on tables too' do
|
29
36
|
dump_io = StringIO.new
|
30
|
-
ActiveRecord::SchemaDumper.dump(
|
37
|
+
ActiveRecord::SchemaDumper.dump(source, dump_io)
|
31
38
|
expect(dump_io.string).to match /t\.interval +"duration"/
|
32
39
|
end
|
33
40
|
end
|
data/spec/tests/schema_spec.rb
CHANGED
@@ -2,6 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe 'Schema' do
|
4
4
|
let(:connection) { ActiveRecord::Base.connection }
|
5
|
+
let(:source) do
|
6
|
+
if Torque::PostgreSQL::AR720
|
7
|
+
ActiveRecord::Base.connection_pool
|
8
|
+
else
|
9
|
+
ActiveRecord::Base.connection
|
10
|
+
end
|
11
|
+
end
|
5
12
|
|
6
13
|
before do
|
7
14
|
connection.instance_variable_set(:@schemas_blacklist, nil)
|
@@ -64,7 +71,7 @@ RSpec.describe 'Schema' do
|
|
64
71
|
|
65
72
|
context 'on schema' do
|
66
73
|
let(:dump_result) do
|
67
|
-
ActiveRecord::SchemaDumper.dump(
|
74
|
+
ActiveRecord::SchemaDumper.dump(source, (dump_result = StringIO.new))
|
68
75
|
dump_result.string
|
69
76
|
end
|
70
77
|
|
@@ -73,8 +73,16 @@ RSpec.describe 'TableInheritance' do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
context 'on schema' do
|
76
|
+
let(:source) do
|
77
|
+
if Torque::PostgreSQL::AR720
|
78
|
+
ActiveRecord::Base.connection_pool
|
79
|
+
else
|
80
|
+
ActiveRecord::Base.connection
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
76
84
|
let(:dump_result) do
|
77
|
-
ActiveRecord::SchemaDumper.dump(
|
85
|
+
ActiveRecord::SchemaDumper.dump(source, (dump_result = StringIO.new))
|
78
86
|
dump_result.string
|
79
87
|
end
|
80
88
|
|
@@ -105,9 +113,12 @@ RSpec.describe 'TableInheritance' do
|
|
105
113
|
|
106
114
|
context 'on schema cache' do
|
107
115
|
let(:schema_cache) { ActiveRecord::Base.connection.schema_cache }
|
108
|
-
let(:schema_cache_connection) { schema_cache.instance_variable_get(:@connection) }
|
109
116
|
let(:schema_cache_reflection) { schema_cache.instance_variable_get(:@schema_reflection) }
|
110
|
-
let(:new_schema_cache) { schema_cache_reflection.send(:cache,
|
117
|
+
let(:new_schema_cache) { schema_cache_reflection.send(:cache, schema_cache_source) }
|
118
|
+
|
119
|
+
let(:schema_cache_source) do
|
120
|
+
schema_cache.instance_variable_get(Torque::PostgreSQL::AR720 ? :@pool : :@connection)
|
121
|
+
end
|
111
122
|
|
112
123
|
subject { Torque::PostgreSQL::AR710 ? new_schema_cache : schema_cache }
|
113
124
|
|
@@ -137,7 +148,8 @@ RSpec.describe 'TableInheritance' do
|
|
137
148
|
end
|
138
149
|
|
139
150
|
context 'on looking up models' do
|
140
|
-
let(:prepare_arguments) { Torque::PostgreSQL::AR710 ? [
|
151
|
+
let(:prepare_arguments) { Torque::PostgreSQL::AR710 ? [schema_cache_source] : nil }
|
152
|
+
let(:prepare_method) { Torque::PostgreSQL::AR720 ? :add_all : :prepare_data_sources }
|
141
153
|
|
142
154
|
after(:all) do
|
143
155
|
schema_cache = ActiveRecord::Base.connection.schema_cache
|
@@ -150,7 +162,7 @@ RSpec.describe 'TableInheritance' do
|
|
150
162
|
'public.posts' => 'ActivityPost',
|
151
163
|
})
|
152
164
|
|
153
|
-
subject.send(
|
165
|
+
subject.send(prepare_method, *prepare_arguments)
|
154
166
|
list = subject.instance_variable_get(:@data_sources_model_names)
|
155
167
|
expect(list).to have_key('public.posts')
|
156
168
|
expect(list['public.posts']).to eql(ActivityPost)
|
@@ -161,7 +173,7 @@ RSpec.describe 'TableInheritance' do
|
|
161
173
|
'products' => 'Product',
|
162
174
|
})
|
163
175
|
|
164
|
-
subject.send(
|
176
|
+
subject.send(prepare_method, *prepare_arguments)
|
165
177
|
list = subject.instance_variable_get(:@data_sources_model_names)
|
166
178
|
expect(list).to_not have_key('products')
|
167
179
|
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: 3.
|
4
|
+
version: 3.4.1
|
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: 2024-
|
11
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -290,7 +290,7 @@ metadata:
|
|
290
290
|
source_code_uri: https://github.com/crashtech/torque-postgresql
|
291
291
|
bug_tracker_uri: https://github.com/crashtech/torque-postgresql/issues
|
292
292
|
changelog_uri: https://github.com/crashtech/torque-postgresql/releases
|
293
|
-
post_install_message:
|
293
|
+
post_install_message:
|
294
294
|
rdoc_options:
|
295
295
|
- "--title"
|
296
296
|
- Torque PostgreSQL
|
@@ -307,8 +307,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
307
|
- !ruby/object:Gem::Version
|
308
308
|
version: 1.8.11
|
309
309
|
requirements: []
|
310
|
-
rubygems_version: 3.
|
311
|
-
signing_key:
|
310
|
+
rubygems_version: 3.4.10
|
311
|
+
signing_key:
|
312
312
|
specification_version: 4
|
313
313
|
summary: ActiveRecord extension to access PostgreSQL advanced resources
|
314
314
|
test_files:
|