Skip to content

Commit

Permalink
Add timestamp type, fix #28
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 committed Oct 30, 2015
1 parent 481673a commit 15313fb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/types.jl
Expand Up @@ -34,6 +34,7 @@ newpgtype(:varchar, 1043, (ASCIIString,UTF8String))
newpgtype(:text, 25, ())
newpgtype(:numeric, 1700, (BigInt,BigFloat))
newpgtype(:date, 1082, ())
newpgtype(:timestamp, 1114, ())
newpgtype(:unknown, 705, (Union,NAtype))
newpgtype(:json, 114, (Dict{AbstractString,Any},))
newpgtype(:jsonb, 3802, (Dict{AbstractString,Any},))
Expand Down Expand Up @@ -61,6 +62,8 @@ end

jldata(::Type{PostgresType{:date}}, ptr::Ptr{UInt8}) = bytestring(ptr)

jldata(::Type{PostgresType{:timestamp}}, ptr::Ptr{UInt8}) = bytestring(ptr)

jldata(::Type{PostgresType{:bool}}, ptr::Ptr{UInt8}) = bytestring(ptr) != "f"

jldata(::Type{PostgresType{:int8}}, ptr::Ptr{UInt8}) = parse(Int64, bytestring(ptr))
Expand Down Expand Up @@ -129,6 +132,10 @@ function pgdata(::PostgresType{:date}, ptr::Ptr{UInt8}, data::AbstractString)
ptr = Dates.DateFormat(ptr)
end

function pgdata(::PostgresType{:timestamp}, ptr::Ptr{UInt8}, data::AbstractString)
ptr = storestring!(ptr, bytestring(data))
end

function pgdata(::Type{PostgresType{:bytea}}, ptr::Ptr{UInt8}, data::Vector{UInt8})
ptr = storestring!(ptr, bytestring("\\x", bytes2hex(data)))
end
Expand Down

0 comments on commit 15313fb

Please sign in to comment.