Skip to content

Commit

Permalink
allow "nothing" returns for evalscript (#110)
Browse files Browse the repository at this point in the history
* allow null returns for evalscript

* do not convert script outputs to string, add tests

---------

Co-authored-by: tan <[email protected]>
  • Loading branch information
aviks and tanmaykm authored Jul 12, 2024
1 parent 13d925a commit 645c8f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ function convert_response(::Type{Dict{AbstractString, AbstractString}}, response
retdict
end

function convert_eval_response(::Any, response::Array)
return [String(r) for r in response]
end
function convert_eval_response(::Any, response)
return String(response)
end

# import Base: ==
# ==(A::Union{T, Nothing}, B::Union{U, Nothing}) where {T<:AbstractString, U<:AbstractString} = A == B
# ==(A::Union{T, Nothing}, B::Union{U, Nothing}) where {T<:Number, U<:Number} = A == B
Expand Down
2 changes: 1 addition & 1 deletion src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ end
# TODO: PipelineConnection and TransactionConnection
function evalscript(conn::RedisConnection, script, numkeys::Integer, args)
response = execute_command(conn, flatten_command("eval", script, numkeys, args))
convert_eval_response(Any, response)
return response
end

#################################################################
Expand Down
7 changes: 7 additions & 0 deletions test/redis_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ function redis_tests(conn = RedisConnection())
@test resp == "OK"
del(conn, ky)

script = "return {10,20}"
resp = evalscript(conn, script, 0, [])
@test resp == [10, 20]

script = "return"
resp = evalscript(conn, script, 0, [])
@test resp === nothing

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

Expand Down

0 comments on commit 645c8f6

Please sign in to comment.