blind_index 2.0.1 → 2.0.2

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
2
  SHA256:
3
- metadata.gz: '085bd0b1267657f9ff1d9cce4dac0f26e1c5359aa8d5d88969fd7b232da71094'
4
- data.tar.gz: a0b856aaafbd264cffec4f0d2d88c51125e32b7e5959b8674ff43c721a7fb8c7
3
+ metadata.gz: 06112a25e062c04740b0a01173300d37c364c05ef3bef0de0fa214e3dfbca61e
4
+ data.tar.gz: 41c534b7fd3266559821bba50d122a08adbf3215212304dc7c911cb62e204596
5
5
  SHA512:
6
- metadata.gz: 147b69fecf7b2366d7b0168019738823f093a3cae9cec6d0452abae2f24c8933b5864eea8d84b59d32ca85370c439612e8667e629690334f31c20f47fb732dba
7
- data.tar.gz: 47c1ce7b7990e5abda27e9fa4991e5437219f645456f3ef4cfcf9891810179103d221eaba6adc8259147634bf702cd14e4313578177013ce422ebb29ba35946b
6
+ metadata.gz: 7f3369a1b5ba9b36be21e18c3a41ea9060c779f7cb2b92c2b2539144acd5fb01d99a797b123f6f7b1a97dd53b92c6ff45ba4c5517e43bf99f3e8363875ade522
7
+ data.tar.gz: 0e5a857dd66532f72635c5ec13f56c4e864f8197533a3d300a5630cda8e9dc2d62b3c3bf771c794df2af668a2249830f6d0ba4e06a396f303131465f17dbd6a2
@@ -1,3 +1,8 @@
1
+ ## 2.0.2 (2020-06-01)
2
+
3
+ - Improved error message for bad key length
4
+ - Fixed `backfill` method with relations for Mongoid
5
+
1
6
  ## 2.0.1 (2020-02-14)
2
7
 
3
8
  - Added `BlindIndex.backfill` method
@@ -117,14 +117,14 @@ module BlindIndex
117
117
  key
118
118
  end
119
119
 
120
- def self.decode_key(key)
120
+ def self.decode_key(key, name: "Key")
121
121
  # decode hex key
122
122
  if key.encoding != Encoding::BINARY && key =~ /\A[0-9a-f]{64}\z/i
123
123
  key = [key].pack("H*")
124
124
  end
125
125
 
126
- raise BlindIndex::Error, "Key must use binary encoding" if key.encoding != Encoding::BINARY
127
- raise BlindIndex::Error, "Key must be 32 bytes" if key.bytesize != 32
126
+ raise BlindIndex::Error, "#{name} must be 32 bytes (64 hex digits)" if key.bytesize != 32
127
+ raise BlindIndex::Error, "#{name} must use binary encoding" if key.encoding != Encoding::BINARY
128
128
 
129
129
  key
130
130
  end
@@ -54,7 +54,7 @@ module BlindIndex
54
54
 
55
55
  relation.merge(or_relation)
56
56
  else
57
- relation.or(attributes.map { |a| {a => nil} })
57
+ relation.merge(relation.unscoped.or(attributes.map { |a| {a => nil} }))
58
58
  end
59
59
  end
60
60
 
@@ -88,11 +88,14 @@ module BlindIndex
88
88
  end
89
89
  end
90
90
 
91
+ # don't need to save records that went from nil => nil
91
92
  records.select! { |r| r.changed? }
92
93
 
93
- with_transaction do
94
- records.each do |record|
95
- record.save!(validate: false)
94
+ if records.any?
95
+ with_transaction do
96
+ records.each do |record|
97
+ record.save!(validate: false)
98
+ end
96
99
  end
97
100
  end
98
101
  end
@@ -11,7 +11,7 @@ module BlindIndex
11
11
  raise ArgumentError, "Missing field for key generation" if bidx_attribute.to_s.empty?
12
12
 
13
13
  c = "\x7E"*32
14
- root_key = hkdf(BlindIndex.decode_key(@master_key), salt: table.to_s, info: "#{c}#{bidx_attribute}", length: 32, hash: "sha384")
14
+ root_key = hkdf(BlindIndex.decode_key(@master_key, name: "Master key"), salt: table.to_s, info: "#{c}#{bidx_attribute}", length: 32, hash: "sha384")
15
15
  hash_hmac("sha256", pack([table, bidx_attribute, bidx_attribute]), root_key)
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module BlindIndex
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blind_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-14 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport