mysql_framework 2.1.8 → 2.1.9

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: 243312b0bb9c568e535dd002ebcf30b8896d433067a10bfdf781ba2c2b47d2c7
4
- data.tar.gz: 62bbf2d7b89889902ecd781050b0ebbb1a4f7c79a6095ba652d92ce7c644b833
3
+ metadata.gz: 91ca6641d16e5f4d344b6749fe9f5291c8f24b23f4f8efb28ac8e76443d61750
4
+ data.tar.gz: 961c49140b91c9ea461a1512d63bb89a5861ed5375386e21e21be1c0e1691f2b
5
5
  SHA512:
6
- metadata.gz: 5fc999ca91c3f06506e0aa41b9ac8c30a23b0322458db992a3849e4842a2045c95605e1994cc0d4a56d01f4e5bd6d910d49a159aebcb157b0150361393d1a174
7
- data.tar.gz: cd9341f57273a1fb72eb3a2c61c1e4837a2966fb04ad41fb6157f39a33b840ae3356d1b3671a80d08a2d86baae89e4c42d7c9876c13d7214c8574c3a1516f339
6
+ metadata.gz: 3b3b3b5ebf141f85110733c54cf6c190e8c091bb681d0e9fc555643efaca73cc29f61964f7ce06142ed48fa466bb49c1f616ff48ba3d44223db12d414e6bcc81
7
+ data.tar.gz: a0119d3cb52bc3d513054fe803f9627dfd6ca0c20f51dc602fcfe36897227bb6ea29933cff88599f1fbb5d7019bad8cf971aedf887b216fbd5a07c55e39f8b33
@@ -127,7 +127,7 @@ module MysqlFramework
127
127
  @sql += " (#{conditions.join(' AND ')}) "
128
128
 
129
129
  conditions.each do |condition|
130
- next if condition.value.nil?
130
+ next if condition.value.nil? && !skip_nil_validation?
131
131
  if condition.value.is_a?(Enumerable)
132
132
  @params.concat(condition.value)
133
133
  else
@@ -263,5 +263,11 @@ module MysqlFramework
263
263
 
264
264
  self
265
265
  end
266
+
267
+ private
268
+
269
+ def skip_nil_validation?
270
+ ENV.fetch('MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION', 'false').downcase == 'true'
271
+ end
266
272
  end
267
273
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MysqlFramework
4
- VERSION = '2.1.8'
4
+ VERSION = '2.1.9'
5
5
  end
@@ -233,6 +233,33 @@ describe MysqlFramework::SqlQuery do
233
233
  expect(subject.sql).to eq('WHERE (`gems`.`author` = ? AND `gems`.`created_at` > ?) AND (`gems`.`name` IN (?, ?))')
234
234
  end
235
235
  end
236
+
237
+ context 'when condition is nil' do
238
+ context 'when MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION is not present' do
239
+ it 'concats the parameter collections' do
240
+ expect { subject.where(gems[:created_at].eq(nil)) }.to raise_error ArgumentError
241
+ end
242
+ end
243
+
244
+ context 'when MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION is present' do
245
+ after(:each) { ENV.delete('MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION') }
246
+
247
+ context 'when value is false' do
248
+ it 'concats the parameter collections' do
249
+ ENV['MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION'] = 'false'
250
+ expect { subject.where(gems[:created_at].eq(nil)) }.to raise_error ArgumentError
251
+ end
252
+ end
253
+
254
+ context 'when value is true' do
255
+ it 'concats the parameter collections' do
256
+ ENV['MYSQL_FRAMEWORK_SKIP_NIL_VALUE_VALIDATION'] = 'true'
257
+ query = subject.where(gems[:updated_at].eq(nil))
258
+ expect(query.params).to eq ['sage', '2018-01-01 00:00:00', nil]
259
+ end
260
+ end
261
+ end
262
+ end
236
263
  end
237
264
 
238
265
  describe '#and' do
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.8
4
+ version: 2.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-29 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake