Skip to content

Commit 14cafa5

Browse files
authored
fix: prevent comparison errors (#82)
1 parent b75a1f1 commit 14cafa5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/redis_client/cluster/router.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def send_command(method, *args, **kwargs, &block) # rubocop:disable Metrics/AbcS
3434
@node.call_primaries(method, *args, **kwargs, &block).first
3535
when 'ping' then @node.send_ping(method, *args, **kwargs, &block).first
3636
when 'wait' then send_wait_command(method, *args, **kwargs, &block)
37-
when 'keys' then @node.call_replicas(method, *args, **kwargs, &block).flatten.sort
38-
when 'dbsize' then @node.call_replicas(method, *args, **kwargs, &block).sum
37+
when 'keys' then @node.call_replicas(method, *args, **kwargs, &block).flatten.sort_by(&:to_s)
38+
when 'dbsize' then @node.call_replicas(method, *args, **kwargs, &block).select { |e| e.is_a?(Integer) }.sum
3939
when 'scan' then scan(*command, **kwargs)
40-
when 'lastsave' then @node.call_all(method, *args, **kwargs, &block).sort
40+
when 'lastsave' then @node.call_all(method, *args, **kwargs, &block).sort_by(&:to_i)
4141
when 'role' then @node.call_all(method, *args, **kwargs, &block)
4242
when 'config' then send_config_command(method, *args, **kwargs, &block)
4343
when 'client' then send_client_command(method, *args, **kwargs, &block)
@@ -221,11 +221,11 @@ def send_pubsub_command(method, *args, **kwargs, &block) # rubocop:disable Metri
221221
command = method == :blocking_call && args.size > 1 ? args[1..] : args
222222

223223
case command[1].to_s.downcase
224-
when 'channels' then @node.call_all(method, *args, **kwargs, &block).flatten.uniq.sort
224+
when 'channels' then @node.call_all(method, *args, **kwargs, &block).flatten.uniq.sort_by(&:to_s)
225225
when 'numsub'
226226
@node.call_all(method, *args, **kwargs, &block).reject(&:empty?).map { |e| Hash[*e] }
227227
.reduce({}) { |a, e| a.merge(e) { |_, v1, v2| v1 + v2 } }
228-
when 'numpat' then @node.call_all(method, *args, **kwargs, &block).sum
228+
when 'numpat' then @node.call_all(method, *args, **kwargs, &block).select { |e| e.is_a?(Integer) }.sum
229229
else assign_node(*command).send(method, *args, **kwargs, &block)
230230
end
231231
end

0 commit comments

Comments
 (0)