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

Updates for Julia 0.7 #40

Merged
merged 6 commits into from
Jul 4, 2018
Merged

Updates for Julia 0.7 #40

merged 6 commits into from
Jul 4, 2018

Conversation

ararslan
Copy link
Contributor

@ararslan ararslan commented Jun 6, 2018

Work in progress, opening now then I'll add commits incrementally.

Fixes #39, #25, #37, #38

circle.yml Outdated
mkdir jlmnt
hdiutil mount -readonly -mountpoint jlmnt julia.dmg
cp -a jlmnt/*.app/Contents/Resources/julia ~/
echo 'PATH=$HOME/bin:$PATH' >> $BASH_ENV
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this from https://discuss.circleci.com/t/how-to-add-a-path-to-path-in-circle-2-0/11554/10, but it doesn't appear to be working properly, hence the failures on Circle.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to source bashrc, like in that link

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But also I think you could either just not use $PATH, or do an install to whatever directory brew is using

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you need that to be `echo 'export PATH=$HOME/bin:$PATH' >> $BASH_ENV

The export is important

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoooooops. Added export and source, but either I'm still derping or modifying the path isn't the right solution.

Previously I tried symlinking the executable to /usr/local/bin but it couldn't find it there, and I tried symlinking to /usr/bin but got a permissions error, even with sudo.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well just reference Julia by path then?

@ararslan ararslan force-pushed the aa/0.7 branch 4 times, most recently from ed05c16 to f29fb98 Compare June 7, 2018 01:53
src/LibPQ.jl Outdated
@@ -3,6 +3,7 @@ module LibPQ
export status, reset!, execute, clear, fetch!, prepare,
num_columns, num_rows, num_params, num_affected_rows

using Compat
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please import specific things rather than everything

src/parsing.jl Outdated
@@ -252,7 +252,7 @@ end
## arrays
# numeric arrays never have double quotes and always use ',' as a separator
function parse_numeric_array(eltype::Type{T}, str::AbstractString) where T
eq_ind = searchindex(str, '=')
eq_ind = something(findfirst(isequal('='), str), 0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just change the eq_ind > 0 check to eq_ind !== nothing and avoid the something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 0.6, this returns 0 rather than nothing when there's no match. something is just a more concise way to handle both versions at once.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh, so this is for cross-version support. Maybe make a comment showing that we can change it when we drop 0.6

test/runtests.jl Outdated
using Compat: Test

import Compat: @__MODULE__
using Compat
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be specific about Compat imports

end

return arr
end

function array_size(str)
ndims = findfirst(c -> c != '{', str) - 1
ndims = something(findfirst(c -> c != '{', str), 0) - 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the something and throw an error on nothing (like "Invalid PostgreSQL array literal '$str'")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also through an error when this is < 0 on 0.6 then?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah keep it as is, I understand better after #40 (comment)


# this should change to be whatever custom pgtype conversion function we invent
map!(parameters, values(row)) do val
map!(parameters, collect(values(row))) do val
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why collect now? What changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that values returns a Tuple rather than an array, which hits a MethodError from map!.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make this a loop assigning to parameters instead then. Don't want to allocate an extra vector for each row.

@ararslan ararslan force-pushed the aa/0.7 branch 3 times, most recently from 9f2cc88 to 38af842 Compare June 28, 2018 23:29
Also add a finalizer for Result that calls `close`. `clear!` has been
moved to the Distributed stdlib package as of Julia v0.7.

The `cleared` field of the `Result` type has been removed in favor of a
general `isopen` method for `Result`s.
@ararslan ararslan changed the title WIP: Updates for Julia 0.7 Updates for Julia 0.7 Jul 4, 2018
@@ -15,12 +15,12 @@ using LibPQ, DataStreams, NamedTuples
conn = LibPQ.Connection("dbname=postgres")
result = execute(conn, "SELECT typname FROM pg_type WHERE oid = 16")
data = Data.stream!(result, NamedTuple)
clear!(result)
close(result)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can stop recommending this by default now that finalizers exist

@iamed2
Copy link
Owner

iamed2 commented Jul 4, 2018

Doctests are failing on 0.7

@ararslan
Copy link
Contributor Author

ararslan commented Jul 4, 2018

Fixed.


# the same but with parameters
result = execute(conn, "SELECT typname FROM pg_type WHERE oid = \$1", ["16"])
data = Data.stream!(result, NamedTuple)
clear!(result)
close(result)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh!

We no longer need to recommend explicitly calling `close` on `Result`s
and we only want to load NamedTuples on 0.6.
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

Successfully merging this pull request may close these issues.

None yet

2 participants