r-dbi / r-dbi/RPostgres

Unable to create table with logical column

Open
#430 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I was not able to create a table with a logical (boolean) column using dbCreateTable. If I define

table_a = c(col_1="character", col_2="numeric", col_3="integer")
table_b = c(col_1="character", col_2="numeric", col_3="logical")

And attempt to create them with dbCreateTable, it works as expected for table_a. However, it fails for table_b giving the following Error: Failed to fetch row: ERROR: type "logical" does not exist at character 75.

I was not able to find a mention of this in the docs or this repo's issues. My apologies in advance if this was an already considered/documented case or simply a misuse on my end.

Full MWE:

import::from(DBI, dbConnect, dbCreateTable)
import::from(RPostgres, Postgres)

table_a = c(col_1="character", col_2="numeric", col_3="integer")
table_b = c(col_1="character", col_2="numeric", col_3="logical")

# Connect to PG, replace with your credentials
conn = dbConnect(
    Postgres(),
    dbname="your_db",
    host="your_host",
    port=5432,
    user="your_name",
    password="your_pwd"
)

dbCreateTable(conn, "TableA", table_a, row.names=NULL)
dbCreateTable(conn, "TableB", table_b, row.names=NULL)

Adittional info:

  • PG: PostgreSQL 14.6 (Debian 14.6-1.pgdg110+1)
  • DBI: Version: 1.1.3, Source: Repository, Repository: CRAN, Hash: b2866e62bab9378c3cc9476a1954226b
  • R: Version: 4.2.2, Patched (2022-11-10 r83330), Platform: x86_64-pc-linux-gnu (64-bit)

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 by reproducing the provided MWE with dbCreateTable, then trace how R logical columns are mapped to PostgreSQL types. Done means a table with a logical column is created successfully, with a regression test covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, r
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.