database_validations 2.1.1 → 2.1.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 255d7abe6bea01a42005aaf476a0956e0b86edbf0916bbac6e79192b3c2437a5
|
|
4
|
+
data.tar.gz: 4ffa2d08d01c26e1ba4975b2b9854c0014fb8343182cb471b7459c6698a20a1c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a71bc5c81efda997c988f1b893b8d5a341a3736069fda623465bdb0e75ed63310dad66b628b47cc4f8bfdfee7595e8ac2aa7e8cea6b4f7f8aeddb8038df6bb6
|
|
7
|
+
data.tar.gz: 75ac1fd340edc2bf7317462cf1b42cb3f0f7ce9557d4746c9003b1838eef2891a403be6065b1c46969fe972b962e7c442fba418f679a0fca1012c83b139755f1
|
|
@@ -8,13 +8,18 @@ module DatabaseValidations
|
|
|
8
8
|
error.message[/unique constraint "([^"]+)"/, 1]
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
# PostgreSQL leaves the `DETAIL: Key (...)=(...) already exists.` line out of a unique violation on a
|
|
12
|
+
# table the current role is subject to row-level security on, because the values could belong to a row the
|
|
13
|
+
# role cannot see. The columns are then unknown (nil) and the error is matched by its index name instead.
|
|
11
14
|
def unique_error_columns(error)
|
|
12
|
-
error.message[/Key \((.+)\)=/, 1]
|
|
15
|
+
error.message[/Key \((.+)\)=/, 1]&.split(', ')
|
|
13
16
|
end
|
|
14
17
|
|
|
18
|
+
# A composite key reports every column, `Key (tenant_id, company_id)=(1, 2)`; each is a candidate, and the
|
|
19
|
+
# rescuer picks the one with a matching `db_belongs_to`.
|
|
15
20
|
def foreign_key_error_column(error)
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
columns = error.message[/Key \(([^)]+)\)/, 1]
|
|
22
|
+
columns ? columns.split(', ') : []
|
|
18
23
|
end
|
|
19
24
|
end
|
|
20
25
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: database_validations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evgeniy Demin
|
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
228
228
|
- !ruby/object:Gem::Version
|
|
229
229
|
version: '0'
|
|
230
230
|
requirements: []
|
|
231
|
-
rubygems_version:
|
|
231
|
+
rubygems_version: 4.0.23
|
|
232
232
|
specification_version: 4
|
|
233
233
|
summary: Provide compatibility between database constraints and ActiveRecord validations
|
|
234
234
|
with better performance and consistency.
|