doltgresql icon indicating copy to clipboard operation
doltgresql copied to clipboard

Connecting to doltgres from R Postgres client fails because of no "SET datestyle"

Open noamross opened this issue 2 years ago • 2 comments

In attempting to get a "Hello, World" working from R, I run doltgres from bash, then in R I run:

library(DBI)
library(RPostgres)

con <- dbConnect(RPostgres::Postgres(), host = "localhost", port = 5432, user = "doltgres", dbname = "doltgres")

I get the following error in R:

Error: Failed to fetch row : ERROR:  column "datestyle" could not be found in any table in scope (errno 1105) (sqlstate HY000)

In the doltgres log I get the same error as a WARN. I get the same error in psql, but it is not a fatal connection error.

This is because the R Postgres client, by default, runs SET datestyle to 'iso, mdy' on connection to standardize the date-time values returned across different Postgres versions, and within R not getting a response is an error (See https://github.com/r-dbi/RPostgres/issues/287 and https://github.com/r-dbi/RPostgres/blob/6d785a2bad98fd3663668fc39f38bbf1677fa1c1/R/dbConnect_PqDriver.R#L93).

noamross avatar Nov 06 '23 17:11 noamross

We don't yet support setting any system parameters in DoltgreSQL. We have a few other features to work through first before we tackle this one, but we appreciate the issue! We'll get to it as soon as we can.

Hydrocharged avatar Nov 10 '23 01:11 Hydrocharged

Update: SET datestyle now works, but it does not update the value yet. The next support needed to connect from R is current_schema() function, used as SELECT current_schema().

jennifersp avatar May 13 '24 21:05 jennifersp

This should work now in 0.11.1. Let us know if you come across anything else!

tbantle22 avatar Aug 21 '24 21:08 tbantle22