JuliaDatabases / PostgreSQL.jl

DEPRECATED: use LibPQ.jl instead
https://github.com/invenia/LibPQ.jl
Other
60 stars 39 forks source link

MethodError: Cannot `convert` an object of type Type{PostgreSQL.OID{107980182}} to an object of type PostgreSQL.PostgresType #55

Open johannspies opened 6 years ago

johannspies commented 6 years ago

Building a query from an array like this:

query = """select A.ut, A.title, S.title as journal, F.field, 
F.organisation, F.suborgname, F.pubtype, F.doctype 
from wos_2017_1.article A, 
wos_2017_1.publication P, 
wos_2017_1.source S, 
basic_sciences.physorgs_mv F 
where A.ut in ($uts)  
and 
P.ut = A.ut 
and  
S.uuid = P.journal_id 
and 
f.ut = A.ut;""" 
query = replace(query, "\n", "")
dfr = get_dbdata(query)

results in a query like this (tuple shortened)

select A.ut, A.title, S.title as journal, F.field, F.organisation, F.suborgname, F.pubtype, F.doctype from wos_2017_1.article A, wos_2017_1.publication P, wos_2017_1.source S, basic_sciences.physorgs_mv F where A.ut in ('WOS:000299093400012', 'WOS:000307517500010') and P.ut = A.ut and S.uuid = P.journal_id and f.ut = A.ut;

which runs without a problem in pgadmin4 but it throws the following error using the abovementioned code:

MethodError: Cannot `convert` an object of type Type{PostgreSQL.OID{107980182}} to an object of type PostgreSQL.PostgresType
This may have arisen from a call to the constructor PostgreSQL.PostgresType(...),
since type constructors fall back to convert methods.

Stacktrace:
 [1] copy!(::Array{DataType,1}, ::Base.Generator{Array{DataType,1},PostgreSQL.##16#18}) at ./abstractarray.jl:572
 [2] _collect(::Type{DataType}, ::Base.Generator{Array{DataType,1},PostgreSQL.##16#18}, ::Base.HasShape) at ./array.jl:363
 [3] PostgreSQL.PostgresResultHandle(::Ptr{Void}) at /home/js/.julia/v0.6/PostgreSQL/src/types.jl:252
 [4] execute at /home/js/.julia/v0.6/PostgreSQL/src/dbi_impl.jl:171 [inlined]
 [5] get_dbdata(::String) at ./In[5]:5
 [6] include_string(::String, ::String) at ./loading.jl:515