inst-jobs 0.15.7 → 0.15.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/backend/active_record.rb +1 -1
- data/lib/delayed/version.rb +1 -1
- data/spec/active_record_job_spec.rb +16 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1382f66d43fa1610da48ad041f448f968fc7fcbf2ba4a40ac6ecd7478fd9a66
|
4
|
+
data.tar.gz: b7346dae4c71daf95b3b26e6d74fbbcaf20fa75678d710a289ce675abe5e06b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61bc1e00bd03205eeefccec0ccc8c9c955ecea06b371903a42523c6f1590c222e4608c4ffd5b6c7858a8a0367552416e1f79eb96de2794469e409173f355448
|
7
|
+
data.tar.gz: 8abae6f577ad0f57f551d7413b11156aa06feb0dfe9ef2d65ed093f17b17a77bdf25fa36ace55811891ba0d3e2d4825c7f7e738ce92e8f5b921f811dd68a353c
|
@@ -45,7 +45,7 @@ module Delayed
|
|
45
45
|
# > Multiple queries sent in a single PQexec call are processed in a single transaction,
|
46
46
|
# unless there are explicit BEGIN/COMMIT commands included in the query string to divide
|
47
47
|
# it into multiple transactions.
|
48
|
-
sql = "SELECT pg_advisory_xact_lock(#{connection.quote_table_name('half_md5_as_bigint')}(#{connection.quote(values['strand'])})); #{sql}" if
|
48
|
+
sql = "SELECT pg_advisory_xact_lock(#{connection.quote_table_name('half_md5_as_bigint')}(#{connection.quote(values['strand'])})); #{sql}" if values["strand"]
|
49
49
|
result = connection.execute(sql, "#{self} Create")
|
50
50
|
job.id = result.values.first.first
|
51
51
|
result.clear
|
data/lib/delayed/version.rb
CHANGED
@@ -267,11 +267,26 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
|
|
267
267
|
skip "Requires Rails 5.2 or greater" unless Rails.version >= '5.2'
|
268
268
|
|
269
269
|
allow(Delayed::Job.connection).to receive(:prepared_statements).and_return(false)
|
270
|
-
allow(Delayed::Job.connection).to receive(:execute).and_call_original.once
|
270
|
+
allow(Delayed::Job.connection).to receive(:execute).with(be_include("pg_advisory_xact_lock"), anything).and_call_original.once
|
271
271
|
allow(Delayed::Job.connection).to receive(:insert).never
|
272
272
|
j = create_job(strand: "test1")
|
273
273
|
allow(Delayed::Job.connection).to receive(:execute).and_call_original
|
274
274
|
expect(Delayed::Job.find(j.id)).to eq j
|
275
275
|
end
|
276
|
+
|
277
|
+
it "creates a non-stranded job in a single statement" do
|
278
|
+
skip "Requires Rails 5.2 or greater" unless Rails.version >= '5.2'
|
279
|
+
|
280
|
+
allow(Delayed::Job.connection).to receive(:prepared_statements).and_return(false)
|
281
|
+
call_count = 0
|
282
|
+
allow(Delayed::Job.connection).to receive(:execute).and_wrap_original do |m, (arg1, arg2)|
|
283
|
+
call_count += 1
|
284
|
+
m.call(arg1, arg2)
|
285
|
+
end
|
286
|
+
allow(Delayed::Job.connection).to receive(:insert).never
|
287
|
+
j = create_job(strand: "test1")
|
288
|
+
expect(call_count).to eq 1
|
289
|
+
expect(Delayed::Job.find(j.id)).to eq j
|
290
|
+
end
|
276
291
|
end
|
277
292
|
end
|