Skip to content

Commit 645c8f6

Browse files
avikstanmaykm
andauthored
allow "nothing" returns for evalscript (#110)
* allow null returns for evalscript * do not convert script outputs to string, add tests --------- Co-authored-by: tan <[email protected]>
1 parent 13d925a commit 645c8f6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/client.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ function convert_response(::Type{Dict{AbstractString, AbstractString}}, response
4646
retdict
4747
end
4848

49-
function convert_eval_response(::Any, response::Array)
50-
return [String(r) for r in response]
51-
end
52-
function convert_eval_response(::Any, response)
53-
return String(response)
54-
end
55-
5649
# import Base: ==
5750
# ==(A::Union{T, Nothing}, B::Union{U, Nothing}) where {T<:AbstractString, U<:AbstractString} = A == B
5851
# ==(A::Union{T, Nothing}, B::Union{U, Nothing}) where {T<:Number, U<:Number} = A == B

src/commands.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ end
215215
# TODO: PipelineConnection and TransactionConnection
216216
function evalscript(conn::RedisConnection, script, numkeys::Integer, args)
217217
response = execute_command(conn, flatten_command("eval", script, numkeys, args))
218-
convert_eval_response(Any, response)
218+
return response
219219
end
220220

221221
#################################################################

test/redis_tests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,13 @@ function redis_tests(conn = RedisConnection())
344344
@test resp == "OK"
345345
del(conn, ky)
346346

347+
script = "return {10,20}"
348+
resp = evalscript(conn, script, 0, [])
349+
@test resp == [10, 20]
350+
351+
script = "return"
352+
resp = evalscript(conn, script, 0, [])
353+
@test resp === nothing
347354

348355
#@test evalscript(conn, "return {'1','2',{'3','Hello World!'}}", 0, []) == ["1"; "2"; ["3","Hello World!"]]
349356

0 commit comments

Comments
 (0)