torque-postgresql 2.4.3 → 2.4.5
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/arel/visitors.rb +1 -1
- data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +2 -2
- data/lib/torque/postgresql/version.rb +1 -1
- data/spec/schema.rb +2 -1
- data/spec/tests/arel_spec.rb +6 -0
- data/spec/tests/belongs_to_many_spec.rb +8 -0
- 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: 06fd189e192b540302d0438f76f85e201a8bdebd15c5112681f7eb3a6d7de296
|
4
|
+
data.tar.gz: d0408fd8ff6663a801c274d6703e00e31ea4ab18bf54ff89e86fc862b39b1bfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a00263e8641f8b9e2b0a5c715c106a68c8478fd6084ea88f880c0719556ad06d79ac5e83e25527640ccdaf1a3b5be7644e4907a0872762180eb036fb70d7db0d
|
7
|
+
data.tar.gz: 2b3f308029481f90727f005ee55f43667f3393bd89ea80e82df4f78726bbeb18519d9b987d2f375838f51d79ae36caabaeec4c80809ef2aeb914e2ffa4237569
|
@@ -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 =
|
28
|
+
value = PostgreSQL::AR610 ? o.value_for_database : o.val
|
29
29
|
return super unless value.is_a?(::Enumerable)
|
30
30
|
quote_array(value, collector)
|
31
31
|
end
|
@@ -25,7 +25,7 @@ module Torque
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def foreign_key
|
28
|
-
@foreign_key ||= options[:foreign_key] || derive_foreign_key.freeze
|
28
|
+
@foreign_key ||= options[:foreign_key]&.to_s || derive_foreign_key.freeze
|
29
29
|
end
|
30
30
|
|
31
31
|
def association_foreign_key
|
@@ -33,7 +33,7 @@ module Torque
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def active_record_primary_key
|
36
|
-
@active_record_primary_key ||= options[:primary_key] || derive_primary_key
|
36
|
+
@active_record_primary_key ||= options[:primary_key]&.to_s || derive_primary_key
|
37
37
|
end
|
38
38
|
|
39
39
|
def join_primary_key(*)
|
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/tests/arel_spec.rb
CHANGED
@@ -64,6 +64,12 @@ RSpec.describe 'Arel' do
|
|
64
64
|
it 'does not break jsonb' do
|
65
65
|
expect { connection.add_column(:authors, :profile, :jsonb, default: []) }.not_to raise_error
|
66
66
|
expect(Author.columns_hash['profile'].default).to eq('[]')
|
67
|
+
|
68
|
+
condition = Author.arel_table['profile'].is_distinct_from([])
|
69
|
+
result = Torque::PostgreSQL::AR610 ? "'[]'" : "ARRAY[]"
|
70
|
+
expect(Author.where(condition).to_sql).to eq(<<~SQL.squish)
|
71
|
+
SELECT "authors".* FROM "authors" WHERE "authors"."profile" IS DISTINCT FROM #{result}
|
72
|
+
SQL
|
67
73
|
end
|
68
74
|
|
69
75
|
it 'works properly when column is an array' do
|
@@ -20,6 +20,14 @@ RSpec.describe 'BelongsToMany' do
|
|
20
20
|
|
21
21
|
model.belongs_to_many(:tests)
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'allows setting up foreign key and primary_key as symbol' do
|
25
|
+
model.belongs_to_many(:tests, foreign_key: :test_ids, primary_key: :test_id)
|
26
|
+
|
27
|
+
reflection = model._reflections['tests']
|
28
|
+
expect(reflection.foreign_key).to be_eql('test_ids')
|
29
|
+
expect(reflection.active_record_primary_key).to be_eql('test_id')
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
context 'on association' 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.4.
|
4
|
+
version: 2.4.5
|
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
|
@@ -305,7 +305,7 @@ licenses:
|
|
305
305
|
metadata:
|
306
306
|
source_code_uri: https://github.com/crashtech/torque-postgresql
|
307
307
|
bug_tracker_uri: https://github.com/crashtech/torque-postgresql/issues
|
308
|
-
post_install_message:
|
308
|
+
post_install_message:
|
309
309
|
rdoc_options:
|
310
310
|
- "--title"
|
311
311
|
- Torque PostgreSQL
|
@@ -322,8 +322,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
322
|
- !ruby/object:Gem::Version
|
323
323
|
version: 1.8.11
|
324
324
|
requirements: []
|
325
|
-
rubygems_version: 3.
|
326
|
-
signing_key:
|
325
|
+
rubygems_version: 3.4.10
|
326
|
+
signing_key:
|
327
327
|
specification_version: 4
|
328
328
|
summary: ActiveRecord extension to access PostgreSQL advanced resources
|
329
329
|
test_files:
|