sequel-activerecord_connection 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: ecd95c01a950e81d89914199827c09d3ef0b95b106cfe0601afa9dd40f395f62
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9f5c69f4291dfd46a1d07476a1fca226aafcdd6e6ef5c0ce697554a3c2d385e3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 85877ab167fbca19e25b366c05f934488f610f23b790cdd360c80e67cf0cecce35104846807f77374671d6e8214008c5aaab88f5ce10d47106060e049dc94f59
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d25ed24c5444c0c6cdfeb91857b42db90f8d3115f1ca678b4e7ec876845255d65737e8e5d2837c633058356ad7ac32ab5da71085c68c5021134765a19a10b7ee
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## HEAD
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Avoid permanent checkout of Active Record 7.2+ connections (@janko)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## 1.4.3 (2024-09-26)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            * Fix compatibility with adapters that don't support savepoints (@janko)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       1 
9 
     | 
    
         
             
            ## 1.4.2 (2024-09-23)
         
     | 
| 
       2 
10 
     | 
    
         | 
| 
       3 
11 
     | 
    
         
             
            * Fix compatibility with newer versions of Oracle Enhanced adapter (@janko)
         
     | 
| 
         @@ -25,10 +25,12 @@ module Sequel 
     | 
|
| 
       25 
25 
     | 
    
         
             
                      fail Error, "#{key.inspect} transaction option is currently not supported" if opts.key?(key)
         
     | 
| 
       26 
26 
     | 
    
         
             
                    end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                    super
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                     
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
                    super do |conn|
         
     | 
| 
      
 29 
     | 
    
         
            +
                      yield conn
         
     | 
| 
      
 30 
     | 
    
         
            +
                    rescue => e
         
     | 
| 
      
 31 
     | 
    
         
            +
                      activerecord_connection.clear_cache! if e.class.name == "ActiveRecord::PreparedStatementCacheExpired"
         
     | 
| 
      
 32 
     | 
    
         
            +
                      raise
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
       32 
34 
     | 
    
         
             
                  end
         
     | 
| 
       33 
35 
     | 
    
         | 
| 
       34 
36 
     | 
    
         
             
                  private
         
     | 
| 
         @@ -39,7 +39,7 @@ module Sequel 
     | 
|
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                # Avoid calling Sequel's connection pool, instead use Active Record's.
         
     | 
| 
       41 
41 
     | 
    
         
             
                def synchronize(*)
         
     | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
      
 42 
     | 
    
         
            +
                  activerecord_synchronize do
         
     | 
| 
       43 
43 
     | 
    
         
             
                    conn = activerecord_connection.raw_connection
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                    if activerecord_connection_class && !conn.is_a?(activerecord_connection_class)
         
     | 
| 
         @@ -47,9 +47,9 @@ module Sequel 
     | 
|
| 
       47 
47 
     | 
    
         
             
                    end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                    yield conn
         
     | 
| 
      
 50 
     | 
    
         
            +
                  ensure
         
     | 
| 
      
 51 
     | 
    
         
            +
                    clear_activerecord_query_cache
         
     | 
| 
       50 
52 
     | 
    
         
             
                  end
         
     | 
| 
       51 
     | 
    
         
            -
                ensure
         
     | 
| 
       52 
     | 
    
         
            -
                  clear_activerecord_query_cache
         
     | 
| 
       53 
53 
     | 
    
         
             
                end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
                # Log executed queries into Active Record logger as well.
         
     | 
| 
         @@ -70,7 +70,10 @@ module Sequel 
     | 
|
| 
       70 
70 
     | 
    
         
             
                # information to know whether we're in a transaction, whether to create a
         
     | 
| 
       71 
71 
     | 
    
         
             
                # savepoint, when to run transaction/savepoint hooks etc.
         
     | 
| 
       72 
72 
     | 
    
         
             
                def _trans(conn)
         
     | 
| 
       73 
     | 
    
         
            -
                  hash = super || {  
     | 
| 
      
 73 
     | 
    
         
            +
                  hash = super || { activerecord: true }
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                  # adapters that don't support savepoints won't have this assigned
         
     | 
| 
      
 76 
     | 
    
         
            +
                  hash[:savepoints] ||= []
         
     | 
| 
       74 
77 
     | 
    
         | 
| 
       75 
78 
     | 
    
         
             
                  # add any ActiveRecord transactions/savepoints that have been opened
         
     | 
| 
       76 
79 
     | 
    
         
             
                  # directly via ActiveRecord::Base.transaction
         
     | 
| 
         @@ -137,7 +140,7 @@ module Sequel 
     | 
|
| 
       137 
140 
     | 
    
         
             
                  end
         
     | 
| 
       138 
141 
     | 
    
         
             
                end
         
     | 
| 
       139 
142 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
                if ActiveRecord.version >= Gem::Version.new("7.2 
     | 
| 
      
 143 
     | 
    
         
            +
                if ActiveRecord.version >= Gem::Version.new("7.2")
         
     | 
| 
       141 
144 
     | 
    
         
             
                  def activerecord_transaction_callback(type, &block)
         
     | 
| 
       142 
145 
     | 
    
         
             
                    activerecord_connection.current_transaction.public_send(type, &block)
         
     | 
| 
       143 
146 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -155,6 +158,14 @@ module Sequel 
     | 
|
| 
       155 
158 
     | 
    
         
             
                  super
         
     | 
| 
       156 
159 
     | 
    
         
             
                end
         
     | 
| 
       157 
160 
     | 
    
         | 
| 
      
 161 
     | 
    
         
            +
                def activerecord_synchronize
         
     | 
| 
      
 162 
     | 
    
         
            +
                  with_activerecord_connection do
         
     | 
| 
      
 163 
     | 
    
         
            +
                    activerecord_lock do
         
     | 
| 
      
 164 
     | 
    
         
            +
                      yield
         
     | 
| 
      
 165 
     | 
    
         
            +
                    end
         
     | 
| 
      
 166 
     | 
    
         
            +
                  end
         
     | 
| 
      
 167 
     | 
    
         
            +
                end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
       158 
169 
     | 
    
         
             
                if ActiveRecord.version >= Gem::Version.new("7.0")
         
     | 
| 
       159 
170 
     | 
    
         
             
                  def clear_activerecord_query_cache
         
     | 
| 
       160 
171 
     | 
    
         
             
                    activerecord_model.clear_query_caches_for_current_thread
         
     | 
| 
         @@ -165,10 +176,22 @@ module Sequel 
     | 
|
| 
       165 
176 
     | 
    
         
             
                  end
         
     | 
| 
       166 
177 
     | 
    
         
             
                end
         
     | 
| 
       167 
178 
     | 
    
         | 
| 
      
 179 
     | 
    
         
            +
                if ActiveRecord.version >= Gem::Version.new("7.2")
         
     | 
| 
      
 180 
     | 
    
         
            +
                  def with_activerecord_connection
         
     | 
| 
      
 181 
     | 
    
         
            +
                    activerecord_model.with_connection(prevent_permanent_checkout: true) do
         
     | 
| 
      
 182 
     | 
    
         
            +
                      yield activerecord_connection
         
     | 
| 
      
 183 
     | 
    
         
            +
                    end
         
     | 
| 
      
 184 
     | 
    
         
            +
                  end
         
     | 
| 
      
 185 
     | 
    
         
            +
                else
         
     | 
| 
      
 186 
     | 
    
         
            +
                  def with_activerecord_connection
         
     | 
| 
      
 187 
     | 
    
         
            +
                    yield activerecord_connection
         
     | 
| 
      
 188 
     | 
    
         
            +
                  end
         
     | 
| 
      
 189 
     | 
    
         
            +
                end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
       168 
191 
     | 
    
         
             
                # Active Record doesn't guarantee that a single connection can only be used
         
     | 
| 
       169 
192 
     | 
    
         
             
                # by one thread at a time, so we need to use locking, which is what Active
         
     | 
| 
       170 
193 
     | 
    
         
             
                # Record does internally as well.
         
     | 
| 
       171 
     | 
    
         
            -
                if ActiveRecord.version >= Gem::Version.new("5.1 
     | 
| 
      
 194 
     | 
    
         
            +
                if ActiveRecord.version >= Gem::Version.new("5.1")
         
     | 
| 
       172 
195 
     | 
    
         
             
                  def activerecord_lock
         
     | 
| 
       173 
196 
     | 
    
         
             
                    activerecord_connection.lock.synchronize do
         
     | 
| 
       174 
197 
     | 
    
         
             
                      ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sequel-activerecord_connection
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.5.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Janko Marohnić
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2024- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-10-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: sequel
         
     |