-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Not sure what can be done about this, but if an SQL expression with parameters expects a float and Inf (or -Inf) is passed, PostgreSQL errs and complains like so:
dbGetQuery(conn, "select 0 + $1", Inf)
## Error: Failed to fetch row: ERROR: invalid input syntax for type integer: "Inf"With an explicit PostgreSQL type cast for the $1 parameter, however:
dbGetQuery(conn, "select 0 + $1::float", Inf)
## # A tibble: 1 x 1
## `?column?`
## <dbl>
## 1 InfThis mirrors what happens in PostgreSQL:
select 0 + 'Infinity'; -- errs
select 0 + 'Infinity'::float; -- succeedsAnd so I don't think this counts as a bug, but it's sneaky in that a RPostgres user would have to protect her queries with type casts if there was any chance the R program would produce Inf as the passed value. Perhaps explicit casting should always be encouraged anyhow, though :-)
In any case, I don't know if this is known to y'all, and perhaps it's worth mentioning in docs (since PostgreSQL does support infinite values, but just requires this extra care in some situations to prevent errors).