database_validations 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0540cd1970a66666d9d87489076205155314a0b6e67c105c053fa61f8f22b19a
4
- data.tar.gz: c8e0a0cac2b2e86571159053e29b840bba391527060adcd501f3f7a4836e0c5e
3
+ metadata.gz: 4817334b7a4a7ae57f43e69be04b5969dbb35dcbb39f4bd2ebc52603cf149a15
4
+ data.tar.gz: b899b604b2f72021269c39372c60acf0fb4a6805e4d3e2b5f606320aa165bb9a
5
5
  SHA512:
6
- metadata.gz: b79ba0d354e4337a39d8182de5dca5080980fa97a2b2d4094cba86347f583b7afa2a61b3c1e7440eaacb0f09344b9dd7dbbea553abf8cb64b361a35c79c7c74b
7
- data.tar.gz: 7a899554d2373b049fc360939ae493dee275648f52d32f243c2c22338e9d643850b6a60749ef524e5bfd8658f47a98209cd87ec3df94f2454650361709221a03
6
+ metadata.gz: d2b50fd0375c72c71ce1a443131a3c16f84118153947a373280ee9b28f6d6572abf3576acbf4be0660e3d436f30abce62d0072c2297c47e557dc894c002ceb74
7
+ data.tar.gz: 53e6a6363cc2d64763e9ba3c6089911dc09950c799ffcdbfd51f7d792e48c04f82cb8fc47435b01fad64567ba7ba625c865788ccaf73e79a3745e734f752fed9
data/README.md CHANGED
@@ -39,8 +39,7 @@ Disadvantages:
39
39
  - Cannot handle multiple validations at once because database raises only one error for all indexes per query.
40
40
  ```ruby
41
41
  class User < ActiveRecord::Base
42
- validates_db_uniqueness_of :email
43
- validates_db_uniqueness_of :name
42
+ validates_db_uniqueness_of :email, :name
44
43
  end
45
44
 
46
45
  original = User.create(name: 'name', email: 'email@mail.com')
@@ -82,10 +81,10 @@ List of supported options from `validates_uniqueness_of` validator:
82
81
  - `scope`: One or more columns by which to limit the scope of the uniqueness constraint.
83
82
  - `message`: Specifies a custom error message (default is: "has already been taken").
84
83
  - `if`: Specifies a method or proc to call to determine if the validation should occur
85
- (e.g. <tt>if: :allow_validation</tt>, or <tt>if: Proc.new { |user| user.signup_step > 2 }</tt>). The method or
84
+ (e.g. `if: :allow_validation`, or `if: Proc.new { |user| user.signup_step > 2 }`). The method or
86
85
  proc should return or evaluate to a `true` or `false` value.
87
86
  - `unless`: Specifies a method or proc to call to determine if the validation should not
88
- occur (e.g. <tt>unless: :skip_validation</tt>, or <tt>unless: Proc.new { |user| user.signup_step <= 2 }</tt>).
87
+ occur (e.g. `unless: :skip_validation`, or `unless: Proc.new { |user| user.signup_step <= 2 }`).
89
88
  The method or proc should return or evaluate to a `true` or `false` value.
90
89
 
91
90
  **Keep in mind**: Both `if` and `unless` options are used only for `valid?` method and provided only for performance reason.
@@ -115,10 +114,10 @@ validates_uniqueness_of :email, allow_nil: true, allow_blank: false, case_sensit
115
114
 
116
115
  List of supported options for `PostgreSQL` only:
117
116
 
118
- - `where`: Specify the conditions to be included as a <tt>WHERE</tt> SQL fragment to
119
- limit the uniqueness constraint lookup (e.g. <tt>where: "(status = 'active')"</tt>).
117
+ - `where`: Specify the conditions to be included as a `WHERE` SQL fragment to
118
+ limit the uniqueness constraint lookup (e.g. `where: "(status = 'active')"`).
120
119
  For backward compatibility, this will be converted automatically
121
- to <tt>conditions: -> { where("(status = 'active')") }</tt> for `valid?` method.
120
+ to `conditions: -> { where("(status = 'active')") }` for `valid?` method.
122
121
 
123
122
  The list of options to add support:
124
123
 
@@ -8,7 +8,7 @@ module DatabaseValidations
8
8
  module_function
9
9
 
10
10
  def factory(model)
11
- case (database = model.connection.adapter_name.downcase.to_sym)
11
+ case (database = model.connection_config[:adapter].downcase.to_sym)
12
12
  when SqliteAdapter::ADAPTER then SqliteAdapter.new(model)
13
13
  when PostgresqlAdapter::ADAPTER then PostgresqlAdapter.new(model)
14
14
  when MysqlAdapter::ADAPTER then MysqlAdapter.new(model)
@@ -2,7 +2,7 @@ module DatabaseValidations
2
2
  module Adapters
3
3
  class SqliteAdapter < BaseAdapter
4
4
  SUPPORTED_OPTIONS = %i[scope message if unless].freeze
5
- ADAPTER = :sqlite
5
+ ADAPTER = :sqlite3
6
6
 
7
7
  def error_columns(error_message)
8
8
  error_message.scan(/#{model.table_name}\.([^,:]+)/).flatten
@@ -1,3 +1,3 @@
1
1
  module DatabaseValidations
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord