with_advisory_lock 3.1.1 → 3.2.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
2
  SHA1:
3
- metadata.gz: 21f4b6ac2afa73ae66983bce969dc1786aab95a7
4
- data.tar.gz: 8b4874809c6356b53d775764f0f7228658bfa9c4
3
+ metadata.gz: e94aa36a41376cf160850770d5a49a3d301aea4e
4
+ data.tar.gz: 1e7ac3e6f61566a8e2fd1da766c762405f8a7502
5
5
  SHA512:
6
- metadata.gz: cd2e76cc799d22fb4b1f67456eb282797337d9580b143d4cb38c26b0f24e45b7bfa8de19c2ab17f5a730bbcd7623654dd1703c43e5deaed9a05d6c3cf0ecebc8
7
- data.tar.gz: 9bdbcafdb615da0af5671191f233b2c458ff1bfe1d63cf0bfff26da4d627070a985b9dc242da14c3a3a1ac511fedbbdb394b62a60172f3f4b430c66f5e24108f
6
+ metadata.gz: 002a011573e173b6957fc7b51023274ed7f34032f2502def7b6b1c9219aa34979552fda5a615816d3b4be246c083a7d9a8d1e71e9bb324a88183ae4a354bdc36
7
+ data.tar.gz: f30b67b87759cf3c085b96e995e9788728c956b1f74f585d5a198100840d65bc427d6844df99420bacf17d3c4dfbc8b108c77cf4b0ca8bc54a03aec1214991b5
data/README.md CHANGED
@@ -158,6 +158,12 @@ end
158
158
 
159
159
  ## Changelog
160
160
 
161
+ ### 3.2.0
162
+
163
+ * [Joshua Flanagan](https://github.com/joshuaflanagan) [added a SQL comment to the lock query for PostgreSQL](https://github.com/ClosureTree/with_advisory_lock/pull/28). Thanks!
164
+
165
+ * [Fernando Luizão](https://github.com/fernandoluizao) found a spurious requirement for `thread_safe`. Thanks for the [fix](https://github.com/ClosureTree/with_advisory_lock/pull/27)!
166
+
161
167
  ### 3.1.1
162
168
 
163
169
  * [Joel Turkel](https://github.com/jturkel) added `require 'active_support'` (it was required, but relied on downstream gems to pull in active_support before pulling in with_advisory_lock). Thanks!
@@ -21,7 +21,8 @@ module WithAdvisoryLock
21
21
  end
22
22
 
23
23
  def execute_successful?(pg_function)
24
- sql = "SELECT #{pg_function}(#{lock_keys.join(',')}) AS #{unique_column_name}"
24
+ comment = lock_name.gsub(/(\/\*)|(\*\/)/, "--")
25
+ sql = "SELECT #{pg_function}(#{lock_keys.join(',')}) AS #{unique_column_name} /* #{comment} */"
25
26
  result = connection.select_value(sql)
26
27
  # MRI returns 't', jruby returns true. YAY!
27
28
  (result == 't' || result == true)
@@ -1,3 +1,3 @@
1
1
  module WithAdvisoryLock
2
- VERSION = Gem::Version.new('3.1.1')
2
+ VERSION = Gem::Version.new('3.2.0')
3
3
  end
@@ -14,6 +14,14 @@ describe 'class methods' do
14
14
  Tag.current_advisory_lock.must_match(/#{lock_name}/)
15
15
  end
16
16
  end
17
+
18
+ it 'can obtain a lock with a name that attempts to disrupt a SQL comment' do
19
+ dangerous_lock_name = 'test */ lock /*'
20
+ Tag.with_advisory_lock(dangerous_lock_name) do
21
+ Tag.current_advisory_lock.must_match(/#{Regexp.escape(dangerous_lock_name)}/)
22
+ end
23
+
24
+ end
17
25
  end
18
26
 
19
27
  describe '.advisory_lock_exists?' do
@@ -19,7 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = %w(lib)
20
20
 
21
21
  gem.add_runtime_dependency 'activerecord', '>= 3.2'
22
- gem.add_runtime_dependency 'thread_safe'
23
22
 
24
23
  gem.add_development_dependency 'yard'
25
24
  gem.add_development_dependency 'minitest'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_advisory_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew McEachen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: thread_safe
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: yard
43
29
  requirement: !ruby/object:Gem::Requirement