diff --git a/lib/redisgraph/connection.rb b/lib/redisgraph/connection.rb index 259c14e..39ea1f1 100644 --- a/lib/redisgraph/connection.rb +++ b/lib/redisgraph/connection.rb @@ -1,19 +1,26 @@ class RedisGraph def connect_to_server(options) @connection = Redis.new(options) - @module_version = module_version() - raise ServerError, "RedisGraph module not loaded." if @module_version.nil? - raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if @module_version < 19900 + check_module_version end # Ensure that the connected Redis server supports modules # and has loaded the RedisGraph module - def module_version() + def check_module_version() redis_version = @connection.info["redis_version"] major_version = redis_version.split('.').first.to_i raise ServerError, "Redis 4.0 or greater required for RedisGraph support." unless major_version >= 4 - modules = @connection.call("MODULE", "LIST") + + begin + modules = @connection.call("MODULE", "LIST") + rescue Redis::CommandError + # Ignore check if the connected server does not support the "MODULE LIST" command + return + end + module_graph = modules.detect { |_name_key, name, _ver_key, _ver| name == 'graph' } - module_graph[3] if module_graph + module_version = module_graph[3] if module_graph + raise ServerError, "RedisGraph module not loaded." if module_version.nil? + raise ServerError, "RedisGraph module incompatible, expecting >= 1.99." if module_version < 19900 end end diff --git a/spec/redisgraph_spec.rb b/spec/redisgraph_spec.rb index 08da1ec..2851bbb 100644 --- a/spec/redisgraph_spec.rb +++ b/spec/redisgraph_spec.rb @@ -89,7 +89,7 @@ def create_graph() it "should print property strings correctly after updates" do q = """MATCH (a {name: 'src1'}) RETURN a""" res = @r.query(q) - expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>TRUE}]]]) + expect(res.resultset).to eq([[[{"name"=>"src1"}, {"color"=>"cyan"}, {"newval"=>true}]]]) end end end