valhammer 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 758eec1c687a507398055fdb46d849004962b1b6
4
- data.tar.gz: bda97ef82eb60f40da4789514710c122897a35ab
2
+ SHA256:
3
+ metadata.gz: 99b18cba7d288d8e79e530a793fd4e6ee68e73fcce75b11d7c1f75425a0c112d
4
+ data.tar.gz: dc7099bf3d0230ea68958c6f5db7b2e740c8de83f7ff0484d3f93bbde2c6dff5
5
5
  SHA512:
6
- metadata.gz: 6a8dc0e51c7b2ebb78fc0a6536be61a49a7b66257807f6dd901e28736631b755c7fdebd4639d350780862af0f8de2fce2846b7a1e55566b435aaee018e1c83a7
7
- data.tar.gz: af035d6d7dab4931dbbabe1fa1602b30fd98610e90b2ec46f8a631749b4ae734caf1774afec8f7f57f495602a6c68a1a534ca7d7aa5466713303630c06a42c89
6
+ metadata.gz: 123317e5a6dcbb7e122ededd970645fb74500c2d2f7bfa8d33b811aa762a7aa647e501e65c85630ef1dbd91ab44cbff498b21651873ff57e94b153e2a60272f2
7
+ data.tar.gz: 810a0bc83526e3388c83a4e9f9296124b17e9660c55b377b7311a1dcefd4377e0b5119ebb2100e1a761b0fb727e984124336ecd52f7511387bf12abc4d3856eb
data/README.md CHANGED
@@ -19,10 +19,8 @@
19
19
 
20
20
  Automatically validate ActiveRecord models based on the database schema.
21
21
 
22
- Author: Shaun Mangelsdorf
23
-
24
22
  ```
25
- Copyright 2015, Australian Access Federation
23
+ Copyright 2015-2016, Australian Access Federation
26
24
 
27
25
  Licensed under the Apache License, Version 2.0 (the "License");
28
26
  you may not use this file except in compliance with the License.
@@ -82,6 +80,11 @@ Generated validations are:
82
80
  * `:length` — added to `string` columns to ensure the value fits in the
83
81
  column
84
82
 
83
+ **SQLite Note:** In SQLite, a `string` column has no default length restriction
84
+ (except for the [hard limit on data size set at compile
85
+ time](https://www.sqlite.org/limits.html)). Valhammer will not apply a `length`
86
+ validation unless the column was created with an explicit limit.
87
+
85
88
  ### Disabling Validators
86
89
 
87
90
  Passing a block to `valhammer` allows some selective calls to `disable` to
@@ -97,13 +97,13 @@ module Valhammer
97
97
  return unless unique_keys.one?
98
98
 
99
99
  scope = unique_keys.first.columns[0..-2]
100
- validations[:uniqueness] = valhammer_unique_opts(scope)
100
+ validations[:uniqueness] = valhammer_unique_opts(column, scope)
101
101
  end
102
102
 
103
- def valhammer_unique_opts(scope)
103
+ def valhammer_unique_opts(column, scope)
104
104
  nullable = scope.select { |c| columns_hash[c].null }
105
-
106
- opts = { allow_nil: true }
105
+ opts = { allow_nil: true,
106
+ case_sensitive: case_sensitive?(column) }
107
107
  opts[:scope] = scope.map(&:to_sym) if scope.any?
108
108
  opts[:if] = -> { nullable.all? { |c| send(c) } } if nullable.any?
109
109
  opts
@@ -150,5 +150,11 @@ module Valhammer
150
150
  reflect_on_all_associations(:belongs_to)
151
151
  .find { |a| a.foreign_key == field }.try(:name)
152
152
  end
153
+
154
+ def case_sensitive?(column)
155
+ return true unless column.respond_to?(:case_sensitive?)
156
+
157
+ column.case_sensitive?
158
+ end
153
159
  end
154
160
  end
@@ -1,3 +1,3 @@
1
1
  module Valhammer
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valhammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun Mangelsdorf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-11 00:00:00.000000000 Z
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -244,8 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  - !ruby/object:Gem::Version
245
245
  version: '0'
246
246
  requirements: []
247
- rubyforge_project:
248
- rubygems_version: 2.5.1
247
+ rubygems_version: 3.0.3
249
248
  signing_key:
250
249
  specification_version: 4
251
250
  summary: Automatically validate ActiveRecord models based on the database schema.