mysql_framework 2.1.1 → 2.1.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: 76573ef7ddc9a996d4bc02f28fad318ca94692eab6df1f7f592229d67f5df3ab
4
- data.tar.gz: fcbf52818c3cf42d451b15d95fe9609a467ff78402ce31cd43cfae74b5d89b9f
3
+ metadata.gz: e296a8fc2b6937d61814f1b2722600dddcc767b88d234cdffe312137698fd0b5
4
+ data.tar.gz: 29a3f6549675f886369c5b42be8722fd026100d1717cb1d58ccce11624fc8088
5
5
  SHA512:
6
- metadata.gz: 7a8011fafcfaab143dc3e74ddd4d00b5f256ef8051e4139df564e96959a79d9b6f8128704303d93e803c7fe8e4482757105152bfc1a60ad8628c2706155e5169
7
- data.tar.gz: a08b82318c591fe884d5276e1eb1447a8a3460b2f3901a74b29b90a4bafaa44e483bedaf5908696f28756fd265b49c80fe7841316df2826fff0f18363763c6dd
6
+ metadata.gz: 4133713152e216029f6c5e1a91d9911fb4df4eb62fe13bad814eb1f7530c6483dde53c3f55e2f19cc92f04758a72ac7d1cf8e7e9e39981b64554e0df2d7f783b
7
+ data.tar.gz: 62ce8b6bfbead9defc37117c9f5385df533e85051e8515ccecf6d3cf247f12afa95a2ef37627b96f109219e8ac2154f68ce5918e0960430014e51da8237bb762
@@ -50,7 +50,12 @@ module MysqlFramework
50
50
  end
51
51
 
52
52
  def invalid_nil_value?(value)
53
+ return false if skip_nil_validation?
53
54
  nil_comparison? == false && value.nil?
54
55
  end
56
+
57
+ def skip_nil_validation?
58
+ ENV.fetch('MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION', 'false').downcase == 'true'
59
+ end
55
60
  end
56
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MysqlFramework
4
- VERSION = '2.1.1'
4
+ VERSION = '2.1.2'
5
5
  end
@@ -3,6 +3,12 @@
3
3
  describe MysqlFramework::SqlCondition do
4
4
  subject { described_class.new(column: 'version', comparison: '=', value: '1.0.0') }
5
5
 
6
+ before :each do
7
+ allow_any_instance_of(MysqlFramework::SqlCondition).to receive(:skip_nil_validation?).and_return(skip_nil_validation)
8
+ end
9
+
10
+ let(:skip_nil_validation) { false }
11
+
6
12
  describe '#to_s' do
7
13
  it 'returns the condition as a string for a prepared statement' do
8
14
  expect(subject.to_s).to eq('version = ?')
@@ -16,6 +22,14 @@ describe MysqlFramework::SqlCondition do
16
22
  it 'does raises an ArgumentError' do
17
23
  expect { subject }.to raise_error(ArgumentError, "Comparison of = requires value to be not nil")
18
24
  end
25
+
26
+ context 'when skip_nil_validation? is true' do
27
+ let(:skip_nil_validation) { true }
28
+
29
+ it 'does not raise an ArgumentError' do
30
+ expect(subject.value).to be_nil
31
+ end
32
+ end
19
33
  end
20
34
  end
21
35
 
@@ -33,6 +47,14 @@ describe MysqlFramework::SqlCondition do
33
47
  it 'raises an ArgumentError if value is set' do
34
48
  expect { subject }.to raise_error(ArgumentError, 'Cannot set value when comparison is IS NULL')
35
49
  end
50
+
51
+ context 'when skip_nil_validation? is true' do
52
+ let(:skip_nil_validation) { true }
53
+
54
+ it 'raises an ArgumentError if value is set' do
55
+ expect { subject }.to raise_error(ArgumentError, 'Cannot set value when comparison is IS NULL')
56
+ end
57
+ end
36
58
  end
37
59
  end
38
60
 
@@ -67,6 +89,14 @@ describe MysqlFramework::SqlCondition do
67
89
  it 'raises an ArgumentError if value is set' do
68
90
  expect { subject }.to raise_error(ArgumentError, 'Cannot set value when comparison is IS NOT NULL')
69
91
  end
92
+
93
+ context 'when skip_nil_validation? is true' do
94
+ let(:skip_nil_validation) { true }
95
+
96
+ it 'raises an ArgumentError if value is set' do
97
+ expect { subject }.to raise_error(ArgumentError, 'Cannot set value when comparison is IS NOT NULL')
98
+ end
99
+ end
70
100
  end
71
101
  end
72
102
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_framework
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
  - Sage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake