torque-postgresql 2.2.1 → 2.2.2
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/adapter/quoting.rb +8 -5
- data/lib/torque/postgresql/version.rb +1 -1
- data/spec/tests/arel_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 573548a4177e130f445da5816cf833bb21508a2612c71fd3f8fc6a78c7ce04fc
|
4
|
+
data.tar.gz: 509acb45a89a55c30a626117c61a5fc23b9a635f041b1ff6549fed4d221a7571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2267add7a9e17636f0f8ee274d5263d065390998e34b513bede849b7f39292a9742432a6ac41a27930c6cbb49216adccdfb09322497177887267452513494c1f
|
7
|
+
data.tar.gz: 5c3c5174170a4f3eb988f6c1c62c56465da91371a3f3d216ba85ba02e1721dce1c99f93e1964bd7f8b9ebd600beed512d4a713349e2435fd686c8bdaa2f0d6d3
|
@@ -6,6 +6,8 @@ module Torque
|
|
6
6
|
module Quoting
|
7
7
|
|
8
8
|
Name = ActiveRecord::ConnectionAdapters::PostgreSQL::Name
|
9
|
+
Column = ActiveRecord::ConnectionAdapters::PostgreSQL::Column
|
10
|
+
ColumnDefinition = ActiveRecord::ConnectionAdapters::ColumnDefinition
|
9
11
|
|
10
12
|
# Quotes type names for use in SQL queries.
|
11
13
|
def quote_type_name(string, schema = nil)
|
@@ -20,11 +22,12 @@ module Torque
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def quote_default_expression(value, column)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
return super unless value.class <= Array &&
|
26
|
+
((column.is_a?(ColumnDefinition) && column.dig(:options, :array)) ||
|
27
|
+
(column.is_a?(Column) && column.array?))
|
28
|
+
|
29
|
+
type = column.is_a?(Column) ? column.sql_type_metadata.sql_type : column.sql_type
|
30
|
+
quote(value) + '::' + type
|
28
31
|
end
|
29
32
|
|
30
33
|
private
|
data/spec/tests/arel_spec.rb
CHANGED
@@ -55,6 +55,12 @@ RSpec.describe 'Arel' do
|
|
55
55
|
after(:context) { Torque::PostgreSQL.config.use_extended_defaults = false }
|
56
56
|
after { Author.reset_column_information }
|
57
57
|
|
58
|
+
it 'does not break the change column default value method' do
|
59
|
+
connection.add_column(:authors, :enabled, :boolean)
|
60
|
+
expect { connection.change_column_default(:authors, :enabled, { from: nil, to: true }) }.not_to raise_error
|
61
|
+
expect(Author.columns_hash['enabled'].default).to eq('true')
|
62
|
+
end
|
63
|
+
|
58
64
|
it 'does not break jsonb' do
|
59
65
|
expect { connection.add_column(:authors, :profile, :jsonb, default: []) }.not_to raise_error
|
60
66
|
expect(Author.columns_hash['profile'].default).to eq('[]')
|
@@ -76,6 +82,13 @@ RSpec.describe 'Arel' do
|
|
76
82
|
expect { connection.add_column(:authors, :tag_ids, :string, array: true, default: value) }.not_to raise_error
|
77
83
|
expect(Author.columns_hash['tag_ids'].default).to eq(value)
|
78
84
|
end
|
85
|
+
|
86
|
+
it 'works with change column default value' do
|
87
|
+
value = ['2', '3']
|
88
|
+
connection.add_column(:authors, :tag_ids, :string, array: true)
|
89
|
+
expect { connection.change_column_default(:authors, :tag_ids, { from: nil, to: value }) }.not_to raise_error
|
90
|
+
expect(Author.columns_hash['tag_ids'].default).to eq(value)
|
91
|
+
end
|
79
92
|
end
|
80
93
|
|
81
94
|
context 'on cast' 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.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|