active_record_shards 5.3.0 → 5.3.1
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 +4 -4
- data/lib/active_record_shards/connection_switcher.rb +20 -0
- metadata +2 -16
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 032e2279ef2f82d2a1a30a171429a7b34b625766fe3a6060ad21141d551c0ca4
         | 
| 4 | 
            +
              data.tar.gz: 169c3f8e0bf7d4f036a23106d8523b5e09756535f289be4da5ec295ec6c1605d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c35a082c7b33926009467f10871177ecb02a2c5dc3b009a1f5d1a889fb49f039ea88bb931cdd80c7cc67763120158748610925ece6d53ee463020388a4690cc5
         | 
| 7 | 
            +
              data.tar.gz: 4acc42ae93f573d60d12384f6f7454b4a85d1a5a13239491cb6b00a10d722dfb1534026119f845b3f8c39c5e0114500099eac6806cc2c8b6864c7c9f74835fde
         | 
| @@ -4,6 +4,8 @@ require 'active_record_shards/shard_support' | |
| 4 4 |  | 
| 5 5 | 
             
            module ActiveRecordShards
         | 
| 6 6 | 
             
              module ConnectionSwitcher
         | 
| 7 | 
            +
                class LegacyConnectionHandlingError < StandardError; end
         | 
| 8 | 
            +
             | 
| 7 9 | 
             
                case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
         | 
| 8 10 | 
             
                when '6.1', '7.0'
         | 
| 9 11 | 
             
                  SHARD_NAMES_CONFIG_KEY = :shard_names
         | 
| @@ -170,6 +172,8 @@ module ActiveRecordShards | |
| 170 172 | 
             
                alias_method :check_config_for_env, :config_for_env
         | 
| 171 173 |  | 
| 172 174 | 
             
                def switch_connection(options)
         | 
| 175 | 
            +
                  ensure_legacy_connection_handling if ActiveRecord.version >= Gem::Version.new('6.1')
         | 
| 176 | 
            +
             | 
| 173 177 | 
             
                  if options.any?
         | 
| 174 178 | 
             
                    if options.key?(:replica)
         | 
| 175 179 | 
             
                      current_shard_selection.on_replica = options[:replica]
         | 
| @@ -185,6 +189,22 @@ module ActiveRecordShards | |
| 185 189 | 
             
                  end
         | 
| 186 190 | 
             
                end
         | 
| 187 191 |  | 
| 192 | 
            +
                def ensure_legacy_connection_handling
         | 
| 193 | 
            +
                  unless legacy_connection_handling_owner.legacy_connection_handling
         | 
| 194 | 
            +
                    raise LegacyConnectionHandlingError, "ActiveRecordShards is _only_ compatible with ActiveRecord `legacy_connection_handling` set to `true`."
         | 
| 195 | 
            +
                  end
         | 
| 196 | 
            +
                end
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                def legacy_connection_handling_owner
         | 
| 199 | 
            +
                  @legacy_connection_handling_owner ||=
         | 
| 200 | 
            +
                    case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
         | 
| 201 | 
            +
                    when '7.0'
         | 
| 202 | 
            +
                      ActiveRecord
         | 
| 203 | 
            +
                    when '6.1'
         | 
| 204 | 
            +
                      ActiveRecord::Base
         | 
| 205 | 
            +
                    end
         | 
| 206 | 
            +
                end
         | 
| 207 | 
            +
             | 
| 188 208 | 
             
                def shard_env
         | 
| 189 209 | 
             
                  ActiveRecordShards.app_env
         | 
| 190 210 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: active_record_shards
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 5.3. | 
| 4 | 
            +
              version: 5.3.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Benjamin Quorning
         | 
| @@ -13,7 +13,7 @@ authors: | |
| 13 13 | 
             
            autorequire: 
         | 
| 14 14 | 
             
            bindir: bin
         | 
| 15 15 | 
             
            cert_chain: []
         | 
| 16 | 
            -
            date:  | 
| 16 | 
            +
            date: 2023-02-14 00:00:00.000000000 Z
         | 
| 17 17 | 
             
            dependencies:
         | 
| 18 18 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 19 19 | 
             
              name: activerecord
         | 
| @@ -97,20 +97,6 @@ dependencies: | |
| 97 97 | 
             
                - - ">="
         | 
| 98 98 | 
             
                  - !ruby/object:Gem::Version
         | 
| 99 99 | 
             
                    version: '0'
         | 
| 100 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 101 | 
            -
              name: mocha
         | 
| 102 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 103 | 
            -
                requirements:
         | 
| 104 | 
            -
                - - ">="
         | 
| 105 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 106 | 
            -
                    version: 1.4.0
         | 
| 107 | 
            -
              type: :development
         | 
| 108 | 
            -
              prerelease: false
         | 
| 109 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 110 | 
            -
                requirements:
         | 
| 111 | 
            -
                - - ">="
         | 
| 112 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 113 | 
            -
                    version: 1.4.0
         | 
| 114 100 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 115 101 | 
             
              name: mysql2
         | 
| 116 102 | 
             
              requirement: !ruby/object:Gem::Requirement
         |