isolator 0.9.0 → 0.10.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
  SHA256:
3
- metadata.gz: 529433e0e838e663f335a5fb493f51d10f16fbde2168c89be72e92c968709593
4
- data.tar.gz: ef33db058e25204e615fae7ee945c738e516e8ae6d63bb93f9660e6e117cb632
3
+ metadata.gz: 3f7e62d7f280c06f8ad704770d5ba5f14198006bccec0ce69e0e1aa99a8b32c7
4
+ data.tar.gz: 4c4aabcfad57d3ba2da54b5e75b7ee057bf25a10d382094d05a04fec2f371c85
5
5
  SHA512:
6
- metadata.gz: 5cb63aa9a96f5931425267193590550cac0614dd15d272bd7d33f7e2aeaad0b7b37a19f5a6f7d8617dce992e946b92c42c3df5829177cbd51b41d8919abdc8c5
7
- data.tar.gz: b4997855a9d813a961491235097a42eee75d55598fb7d33d53bb4f7e3828f486ea0a2fb788edd028237e39518a2d8e962824b08a3f4cbed2ce3ac22acdfee9c3
6
+ metadata.gz: 565c283a6ddebe9e7d39472094f44f346a1ea1b49afc5ad9fe7aee1ecb98e5910fd5cdc4c0804c581132363338e39465faadab3f51eccbddaea8f731225fd364
7
+ data.tar.gz: ab01a1494c0fac2c1920bced02ae86c6b6b26a6e420f3ef6e43fdd1bd300e14e259c3353b9af08b14787b5ebe499d816222998e837d0af4e16006d9c77a9f5d1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.10.0 (2023-08-15)
6
+
7
+ - Support multiple databases with DatabaseCleaner. ([@palkan][])
8
+
9
+ - Fix query having invalid characters. ([@tagirahmad][])
10
+
11
+ Fixes [#43](https://github.com/palkan/isolator/issues/43).
12
+
5
13
  ## 0.9.0 (2023-05-18)
6
14
 
7
15
  - Support keyword arguments to isolated method in Ruby 3.0. ([@Mange][])
@@ -109,3 +117,5 @@ This, for example, makes Isolator compatible with Rails multi-database apps.
109
117
  [@mquan]: https://github.com/mquan
110
118
  [@bobbymcwho]: https://github.com/bobbymcwho
111
119
  [@Mange]: https://github.com/Mange
120
+ [@tomgi]: https://github.com/tomgi
121
+ [@tagirahmad]: https://github.com/tagirahmad
@@ -33,7 +33,8 @@ module Isolator
33
33
 
34
34
  Module.new do
35
35
  define_method method_name do |*args, **kwargs, &block|
36
- adapter.notify(caller, self, *args, **kwargs)
36
+ # check if we are even notifying before calling `caller`, which is well known to be slow
37
+ adapter.notify(caller, self, *args, **kwargs) if adapter.notify?(*args, **kwargs)
37
38
  super(*args, **kwargs, &block)
38
39
  end
39
40
  end
@@ -7,5 +7,6 @@ adapter = Isolator.isolate :webmock,
7
7
  }
8
8
 
9
9
  WebMock.after_request do |*args|
10
- adapter.notify(caller, *args)
10
+ # check if we are even notifying before calling `caller`, which is well known to be slow
11
+ adapter.notify(caller, *args) if adapter.notify?(*args)
11
12
  end
@@ -1,16 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "database_cleaner/active_record/transaction"
4
-
5
4
  ::DatabaseCleaner::ActiveRecord::Transaction.prepend(
6
5
  Module.new do
7
6
  def start
8
7
  super
9
- Isolator.transactions_threshold += 1
8
+ connection_id = connection_class.connection.object_id
9
+ Isolator.set_connection_threshold(
10
+ Isolator.transactions_threshold(connection_id) + 1,
11
+ connection_id
12
+ )
10
13
  end
11
14
 
12
15
  def clean
13
- Isolator.transactions_threshold -= 1
16
+ connection_id = connection_class.connection.object_id
17
+ Isolator.set_connection_threshold(
18
+ Isolator.transactions_threshold(connection_id) - 1,
19
+ connection_id
20
+ )
14
21
  super
15
22
  end
16
23
  end
@@ -10,8 +10,10 @@ module Isolator
10
10
  def self.subscribe!(event)
11
11
  ::ActiveSupport::Notifications.subscribe(event) do |_name, _start, _finish, _id, query|
12
12
  connection_id = query[:connection_id] || query[:connection]&.object_id || 0
13
- Isolator.incr_transactions!(connection_id) if START_PATTERN.match?(query[:sql])
14
- Isolator.decr_transactions!(connection_id) if FINISH_PATTERN.match?(query[:sql])
13
+ # Prevents "ArgumentError: invalid byte sequence in UTF-8" by replacing invalid byte sequence with "?"
14
+ sanitized_query = query[:sql].encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "?")
15
+ Isolator.incr_transactions!(connection_id) if START_PATTERN.match?(sanitized_query)
16
+ Isolator.decr_transactions!(connection_id) if FINISH_PATTERN.match?(sanitized_query)
15
17
  end
16
18
  end
17
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Isolator
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isolator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-18 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sniffer