Skip to content

Commit

Permalink
Merge pull request #39 from JuliaDB/fixtests
Browse files Browse the repository at this point in the history
Fix JSON test
  • Loading branch information
iamed2 committed Jun 23, 2016
2 parents 218ea68 + 206795e commit 0d13f02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ function pgdata(::Type{PostgresType{:unknown}}, ptr::Ptr{UInt8}, data)
ptr = storestring!(ptr, string(data))
end

function pgdata(::Type{PostgresType{:json}}, ptr::Ptr{UInt8}, data::Dict{AbstractString,Any})
function pgdata{T<:AbstractString}(::Type{PostgresType{:json}}, ptr::Ptr{UInt8}, data::Dict{T,Any})
ptr = storestring!(ptr, bytestring(JSON.json(data)))
end

function pgdata(::Type{PostgresType{:jsonb}}, ptr::Ptr{UInt8}, data::Dict{AbstractString,Any})
function pgdata{T<:AbstractString}(::Type{PostgresType{:jsonb}}, ptr::Ptr{UInt8}, data::Dict{T,Any})
ptr = storestring!(ptr, bytestring(JSON.json(data)))
end

Expand Down
3 changes: 1 addition & 2 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ end
function test_json()
PGType = PostgreSQL.PostgresType
for typ in Any[PGType{:json}, PGType{:jsonb}]
dict1 = @compat Dict{AbstractString,Any}("bobr dobr" => [1, 2, 3])
dict1 = @compat Dict("bobr dobr" => [1, 2, 3], "foo" => 3.0)
p = PostgreSQL.pgdata(typ, convert(Ptr{UInt8}, C_NULL), dict1)
try
dict2 = PostgreSQL.jldata(typ, p)
@test typeof(dict1) == typeof(dict2)
@test dict1 == dict2
finally
Libc.free(p)
Expand Down

0 comments on commit 0d13f02

Please sign in to comment.