Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-numeric arrays support #58

Open
aplavin opened this issue Dec 6, 2018 · 5 comments
Open

Non-numeric arrays support #58

aplavin opened this issue Dec 6, 2018 · 5 comments

Comments

@aplavin
Copy link

aplavin commented Dec 6, 2018

Hi! Is it possible to automatically convert postgres arrays to julia arrays? E.g. when there is array_agg in the query.

@iamed2
Copy link
Owner

iamed2 commented Dec 6, 2018

Yes, and this should already work; please give me examples where it doesn't and I will attempt to fix any issues :)

@aplavin
Copy link
Author

aplavin commented Dec 6, 2018

@iamed2 well, here is a very simple reproducible example:

fetch!(NamedTuple, execute(conn, "
select array_agg(schemaname)
from pg_tables
")).array_agg[1]

gives a string, which in my case looks like this:

"{public,public,public,pg_catalog,pg_catalog,public,public,public,public,public,public,public,public,public,public,public,pg_catalog,pg_catalog,pg_catalog,public,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,pg_catalog,information_schema,information_schema,information_schema,information_schema,information_schema,information_schema,information_schema,pg_catalog,public,public,public,public,public}"

instead of an array of strings.

And now, after looking into LibPQ.jl code, I see that numeric arrays are supported. However, string- and other are not, right?

@iamed2 iamed2 changed the title Arrays support Non-numeric arrays support Dec 6, 2018
@iamed2
Copy link
Owner

iamed2 commented Dec 6, 2018

I've changed the title; currently I support numeric arrays only. I need to add escaping support in order to support text.

@aplavin
Copy link
Author

aplavin commented Dec 6, 2018

That would be useful indeed. I'm not familiar with the postgres api, does it just return everything as strings and you parse them into whatever datatype?

@iamed2
Copy link
Owner

iamed2 commented Dec 6, 2018

Yes, if you use the text format, which I do right now. Lines 268-346 in src/parsing.jl contain the current code for parsing numeric arrays, if you're interested in making a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants