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: db1e6ff10f0fdc62b44c930403abe235abb7453197648ec2a0b02cb2230cd8da
4
- data.tar.gz: 71d5ed3189a8f8a3d0eb9b407e8ca18419632cb2764da5c880f5bebff7e995f7
3
+ metadata.gz: 255d7abe6bea01a42005aaf476a0956e0b86edbf0916bbac6e79192b3c2437a5
4
+ data.tar.gz: 4ffa2d08d01c26e1ba4975b2b9854c0014fb8343182cb471b7459c6698a20a1c
5
5
  SHA512:
6
- metadata.gz: 6c1182c71cebae1d74f81ab204dcf3dd99890b0c88b3596acefd146e7f392e6bf713072d031b12d7c203d76d54c182bf12f17ab6aacbdea1dd3c708e6c420eaa
7
- data.tar.gz: b197cf9d7159bec4ab76aa277c79fc5870107935d8f4798fb857fcd0589917f1ca29c86025759d3e9b10366a901c72e605dadd46dc96f3847cf0fe4e3852f09e
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].split(', ')
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
- column = error.message[/Key \(([^)]+)\)/, 1]
17
- column ? [column] : []
21
+ columns = error.message[/Key \(([^)]+)\)/, 1]
22
+ columns ? columns.split(', ') : []
18
23
  end
19
24
  end
20
25
  end
@@ -1,3 +1,3 @@
1
1
  module DatabaseValidations
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.1.2'.freeze
3
3
  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.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: 3.6.9
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.