switchman 3.5.19 → 3.5.21

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: c0df62cfbd91bd2c05864fbae14ed6f7090ff31c2fe8c4d3915956604f20532f
4
- data.tar.gz: aa2f7a2aaabb1133136df74e596336a5cbc0273d035d30fc07a55bfb597810ab
3
+ metadata.gz: 1aea9491a7cf89144f7952499f7194d6a5e975959298300c308e7ff7d5d23137
4
+ data.tar.gz: 62d4da92da4c56faa42681cfeed6f41d41a0dd004ded08501093036167d7f0c7
5
5
  SHA512:
6
- metadata.gz: b805a3291f0b67e1682c3f73cb78d2aba912afb40e981260671951147af4e577d05eb00cce9849569368543e9f5c683898193dc754bf3e83cb965e4d77b00808
7
- data.tar.gz: 9d4dd4b68faf8596e85e291e6f0f55882645ca81a9225191235ebd2ecf20cc546378ce96bcefa0149d5f4794f15e27f95dde594643ba22e561306d60c3da51a4
6
+ metadata.gz: b53e691f7bb0f31814133f17d0344538e193e13559bb5ffc2c9355dd5cadab146341f750d0588daf0c38b33c1a65be866ef3064f0162365050c0a875a48bf4ea
7
+ data.tar.gz: 43eec8da243a69a386e3873208ac1d7d511ac703c44fce3c4bbb0c8efc000d59aafc9b9112c2874de8aaf698c5c4590bda5af48345d35d669422a794c93386f8
@@ -277,7 +277,7 @@ module Switchman
277
277
  end
278
278
 
279
279
  reflection = self.class.send(:reflection_for_integer_attribute, attr_name)
280
- super(::Switchman::Shard.relative_id_for(
280
+ super(attr_name, ::Switchman::Shard.relative_id_for(
281
281
  new_value,
282
282
  ::Switchman::Shard.current(connection_class_for_self_for_reflection(reflection)),
283
283
  shard
@@ -106,6 +106,45 @@ module Switchman
106
106
  compact_grouped_calculation_rows(rows, opts)
107
107
  end
108
108
 
109
+ if ::Rails.version >= "7.1"
110
+ def ids
111
+ return super unless klass.sharded_primary_key?
112
+
113
+ if loaded?
114
+ result = records.map do |record|
115
+ Shard.relative_id_for(record._read_attribute(primary_key),
116
+ record.shard,
117
+ Shard.current(klass.connection_class_for_self))
118
+ end
119
+ return @async ? Promise::Complete.new(result) : result
120
+ end
121
+
122
+ if has_include?(primary_key)
123
+ relation = apply_join_dependency.group(primary_key)
124
+ return relation.ids
125
+ end
126
+
127
+ columns = arel_columns([primary_key])
128
+ base_shard = Shard.current(klass.connection_class_for_self)
129
+ activate do |r|
130
+ relation = r.spawn
131
+ relation.select_values = columns
132
+
133
+ result = if relation.where_clause.contradiction?
134
+ ActiveRecord::Result.empty
135
+ else
136
+ skip_query_cache_if_necessary do
137
+ klass.connection.select_all(relation, "#{klass.name} Ids", async: @async)
138
+ end
139
+ end
140
+
141
+ result.then do |res|
142
+ type_cast_pluck_values(res, columns).map { |id| Shard.relative_id_for(id, Shard.current, base_shard) }
143
+ end
144
+ end
145
+ end
146
+ end
147
+
109
148
  private
110
149
 
111
150
  def type_cast_calculated_value_switchman(value, column_name, operation)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "3.5.19"
4
+ VERSION = "3.5.21"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.19
4
+ version: 3.5.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-02-20 00:00:00.000000000 Z
13
+ date: 2024-02-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord