Skip to content

Commit e87b3a5

Browse files
committed
fix pgtype for Compat.ASCIIString
1 parent ae714f0 commit e87b3a5

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

src/types.jl

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,7 @@ abstract AbstractOID
99
type OID{N} <: AbstractOID end
1010

1111
oid{T<:AbstractPostgresType}(t::Type{T}) = convert(OID, t)
12-
13-
if VERSION < v"0.5-dev+4194"
14-
import Compat
15-
16-
function pgtype(t::Type)
17-
if t <: Compat.ASCIIString
18-
convert(PostgresType, String)
19-
elseif t <: Vector{Compat.ASCIIString}
20-
convert(PostgresType, Vector{String})
21-
else
22-
convert(PostgresType, t)
23-
end
24-
end
25-
26-
function pgdata(::Type{PostgresType{:_varchar}}, ptr::Ptr{UInt8}, data::Vector{Compat.ASCIIString})
27-
ptr = storestring!(ptr, string("{", join(data, ','), "}"))
28-
end
29-
30-
function pgdata(::Type{PostgresType{:_text}}, ptr::Ptr{UInt8}, data::Vector{Compat.ASCIIString})
31-
ptr = storestring!(ptr, string("{", join(data, ','), "}"))
32-
end
33-
else
34-
pgtype(t::Type) = convert(PostgresType, t)
35-
end
12+
pgtype(t::Type) = convert(PostgresType, t)
3613

3714
Base.convert{T}(::Type{Oid}, ::Type{OID{T}}) = convert(Oid, T)
3815

@@ -289,3 +266,17 @@ function Base.copy(rh::PostgresResultHandle)
289266
PG_COPYRES_NOTICEHOOKS | PG_COPYRES_EVENTS), copy(rh.types), rh.ntuples, rh.nfields)
290267
end
291268

269+
if VERSION < v"0.5-dev+4194"
270+
import Compat
271+
272+
pgtype{T<:Compat.ASCIIString}(::Type{T}) = convert(PostgresType, String)
273+
pgtype{T<:Vector{Compat.ASCIIString}}(::Type{T}) = convert(PostgresType, Vector{String})
274+
275+
function pgdata(::Type{PostgresType{:_varchar}}, ptr::Ptr{UInt8}, data::Vector{Compat.ASCIIString})
276+
ptr = storestring!(ptr, string("{", join(data, ','), "}"))
277+
end
278+
279+
function pgdata(::Type{PostgresType{:_text}}, ptr::Ptr{UInt8}, data::Vector{Compat.ASCIIString})
280+
ptr = storestring!(ptr, string("{", join(data, ','), "}"))
281+
end
282+
end

0 commit comments

Comments
 (0)