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

Support and default to UUID for PostgreSQL uuid #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iamed2
Copy link
Collaborator

@iamed2 iamed2 commented Oct 27, 2022

Closes #260

This adds binary format parsing for UUID and sets the default Julia type for PostgreSQL's uuid to Base.UUID. The import relies on the UUIDs stdlib export for stability's sake.

Array support was easy enough to add as well.

Open question on whether changing the default type away from the String fallback needs a major version update: https://discourse.julialang.org/t/anyone-fetching-uuids-using-libpq-jl/89395/3

I think if people conclude it does, I'll change to ensure this doesn't set the default but still supports the same operations when UUID is specified.

Comment on lines +1422 to +1424
@testset "UUID" begin
tests = (
("'6dc2b682-a411-a51f-ce9e-af63d1ef7c1a'::uuid", UUID("6dc2b682-a411-a51f-ce9e-af63d1ef7c1a")),
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@testset "UUID" begin
tests = (
("'6dc2b682-a411-a51f-ce9e-af63d1ef7c1a'::uuid", UUID("6dc2b682-a411-a51f-ce9e-af63d1ef7c1a")),
@testset "Parameters" begin
conn = LibPQ.Connection(
"dbname=postgres user=$DATABASE_USER"; throw_error=true

Comment on lines +1427 to +1430
@testset for (pg_str, obj) in tests
result = execute(conn, "SELECT $pg_str = \$1", [obj])
@test first(first(result))
close(result)
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@testset for (pg_str, obj) in tests
result = execute(conn, "SELECT $pg_str = \$1", [obj])
@test first(first(result))
close(result)
@testset "UUID" begin
tests = ((
"'6dc2b682-a411-a51f-ce9e-af63d1ef7c1a'::uuid",
UUID("6dc2b682-a411-a51f-ce9e-af63d1ef7c1a"),
),)
@testset for (pg_str, obj) in tests
result = execute(conn, "SELECT $pg_str = \$1", [obj])
@test first(first(result))
close(result)
end

@test first(first(result))
close(result)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end

@robsmith11
Copy link

Seems to work well. Can it be merged?

@rofinn
Copy link
Contributor

rofinn commented Feb 14, 2023

LGTM, reminder to bump the minor release. I'm inclined to holdoff on changing the String fallback for now. Might want to make an issue for it though?

@rofinn rofinn self-requested a review February 14, 2023 23:07
@robsmith11
Copy link

Good to merge?

@rofinn
Copy link
Contributor

rofinn commented May 15, 2023

No, this MR needs a rebase before we can proceed.

@robsmith11
Copy link

Rebased:
#288

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.

Support UUIDs with binary_format=true
3 participants