r-dbi / r-dbi/RPostgres

Option to convert "enum" types to factor or character?

Open
#455 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
343
Forks
82
Avg merge
11h 26m
Merged PRs (30d)
9

Description

My wife has a scenario where she's pulling in a number of columns that end up with a class of "pq_stuff_enum". She doesn't really care that its an enum, and would really like it to come through as a character or possibly a factor.

It seems like typcategory has a category code E for enums:
https://www.postgresql.org/docs/current/catalog-pg-type.html

I wonder if we can detect that when pulling the column in? Maybe around here?
https://github.com/r-dbi/RPostgres/blob/f15f8f445def9e24ff98e4bfc910efcf705c85aa/src/PqResultImpl.cpp#L115

I could see a dbConnect() argument with something like enum = c("enum", "character", "factor") or something similar as a way to control how these are handled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/PqResultImpl.cpp around line 115 and the PostgreSQL pg_type documentation, focusing on typcategory E for enum columns. Review the unresolved discussion to determine the intended dbConnect() option and conversion choices. Done means the agreed enum handling is implemented and its behavior is verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, r
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.