mysql_framework 2.1.7 → 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: d7cfae16762fc02981eed438b941a6eddbf69df7f24d7d7a6c390604064518da
4
- data.tar.gz: aba1911d97941727399a9bd815df8453b276761c736ced329298f8c18b65f69e
3
+ metadata.gz: 91ca6641d16e5f4d344b6749fe9f5291c8f24b23f4f8efb28ac8e76443d61750
4
+ data.tar.gz: 961c49140b91c9ea461a1512d63bb89a5861ed5375386e21e21be1c0e1691f2b
5
5
  SHA512:
6
- metadata.gz: ee9ad256b44ed8ec1db8b9039a72324d3045d5e5b2063c88d64605f63c3bf089d4da383cb1ebece12027dea5a20a7d98734e90192874ce2340244286cea2a0fc
7
- data.tar.gz: 5d867a1db81ccb22887246584ee8020a934e88f11bc5f434ff07e5a1100c89601d13e151406b9c924073a46c72ca3d26b82a4965a1bb02c846cd3239bfc66ebc
6
+ metadata.gz: 3b3b3b5ebf141f85110733c54cf6c190e8c091bb681d0e9fc555643efaca73cc29f61964f7ce06142ed48fa466bb49c1f616ff48ba3d44223db12d414e6bcc81
7
+ data.tar.gz: a0119d3cb52bc3d513054fe803f9627dfd6ca0c20f51dc602fcfe36897227bb6ea29933cff88599f1fbb5d7019bad8cf971aedf887b216fbd5a07c55e39f8b33
@@ -8,7 +8,7 @@ module MysqlFramework
8
8
  end
9
9
 
10
10
  def execute
11
- lock_manager.with_lock(key: self.class) do
11
+ lock_manager.with_lock(key: self.class.name) do
12
12
  initialize_script_history
13
13
 
14
14
  executed_scripts = retrieve_executed_scripts
@@ -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.7'
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.7
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-08-28 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