r-dbi / RPostgres

A DBI-compliant interface to PostgreSQL
https://rpostgres.r-dbi.org
Other
328 stars 78 forks source link

Bigints in dbQuoteLiteral #435

Closed karawoo closed 1 year ago

karawoo commented 1 year ago

I noticed that dbQuoteLiteral() casts integer64 values as floats:

library("DBI")
conn <- dbConnect(RPostgres::Postgres())

(x <- bit64::as.integer64(1))
#> integer64
#> [1] 1
dbQuoteLiteral(conn, x)
#> <SQL> 1::float8

I'd expect <SQL> 1::int8 instead. Would you consider a PR to support bigints here?

krlmlr commented 1 year ago

Thanks. If we support this in dbDataType(), we should also make sure to support it with dbBind() and perhaps dbWriteTable() . I wonder how much work that would be.

karawoo commented 1 year ago

I believe it is already supported in those places as of v1.1.0 https://github.com/r-dbi/RPostgres/blob/main/NEWS.md#rpostgres-110-2018-04-04

Values of class "integer64" are now supported for dbWriteTable() and dbBind() (#178).

krlmlr commented 1 year ago

Thanks, good catch. I agree that we should definitely fix dbDataType() .

github-actions[bot] commented 1 week ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.