Skip to content

Commit 9ffba1d

Browse files
Skip module check if server doesn't support MODULE LIST (#16)
1 parent c28cc03 commit 9ffba1d

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/redisgraph/connection.rb

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
class RedisGraph
22
def connect_to_server(options)
33
@connection = Redis.new(options)
4-
@module_version = module_version()
5-
raise ServerError, "RedisGraph module not loaded." if @module_version.nil?
6-
raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if @module_version < 19900
4+
check_module_version
75
end
86

97
# Ensure that the connected Redis server supports modules
108
# and has loaded the RedisGraph module
11-
def module_version()
9+
def check_module_version()
1210
redis_version = @connection.info["redis_version"]
1311
major_version = redis_version.split('.').first.to_i
1412
raise ServerError, "Redis 4.0 or greater required for RedisGraph support." unless major_version >= 4
15-
modules = @connection.call("MODULE", "LIST")
13+
14+
begin
15+
modules = @connection.call("MODULE", "LIST")
16+
rescue Redis::CommandError
17+
# Ignore check if the connected server does not support the "MODULE LIST" command
18+
return
19+
end
20+
1621
module_graph = modules.detect { |_name_key, name, _ver_key, _ver| name == 'graph' }
17-
module_graph[3] if module_graph
22+
module_version = module_graph[3] if module_graph
23+
raise ServerError, "RedisGraph module not loaded." if module_version.nil?
24+
raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if module_version < 19900
1825
end
1926
end

spec/redisgraph_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def create_graph()
8989
it "should print property strings correctly after updates" do
9090
q = """MATCH (a {name: 'src1'}) RETURN a"""
9191
res = @r.query(q)
92-
expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>TRUE}]]])
92+
expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>true}]]])
9393
end
9494
end
9595
end

0 commit comments

Comments
 (0)