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

feat(c/driver/postgresql): Add enum type support #1485

Merged
merged 8 commits into from
Jan 31, 2024

Conversation

paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Jan 23, 2024

Closes #1483.

This was pretty straightforward because the COPY representation is the same as a string.

I also moved all the COPY examples to the common header (since only a few were missing and it seemed odd that some of them were in different spots).

From R:

library(adbcdrivermanager)

db <- adbc_database_init(
  adbcpostgresql::adbcpostgresql(),
  uri = "postgresql://localhost:5432/postgres?user=postgres&password=password") 

db |> 
  execute_adbc("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy')")

db |> 
  adbc_database_release()

# Have to recreate the database after because that's where we cache the types
con <- db <- adbc_database_init(
    adbcpostgresql::adbcpostgresql(),
    uri = "postgresql://localhost:5432/postgres?user=postgres&password=password"
  ) |> 
  adbc_connection_init()

con |> 
  execute_adbc("CREATE TABLE x (a mood)") |> 
  execute_adbc("INSERT INTO x VALUES ('sad')") |> 
  execute_adbc("INSERT INTO x VALUES ('ok')")

# Returns as string because that's how the driver sees it
con |> 
  read_adbc("SELECT * from x") |> 
  as.data.frame()
#>     a
#> 1 sad
#> 2  ok

Created on 2024-01-23 with reprex v2.0.2

@github-actions github-actions bot added this to the ADBC Libraries 0.10.0 milestone Jan 23, 2024
@paleolimbot paleolimbot marked this pull request as ready for review January 31, 2024 14:16
Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

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

Thanks!

@lidavidm lidavidm merged commit 12ea8b6 into apache:main Jan 31, 2024
54 checks passed
@paleolimbot paleolimbot deleted the c-postgres-enum branch February 6, 2024 21:20
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.

c/driver/postgresql: Support enum type
2 participants