Skip to content

Postgres: substring generates numeric arguments instead of integer #378

@dfrankow

Description

@dfrankow

Brief description of the problem:

library(dbplyr)

translate_sql(substring('abcdefghijklmno', 6,7))
#> Expected: <SQL> substring('abcdefghijklmno', 6, 7)
#> Actual: <SQL> substring('abcdefghijklmno', 6.0, 7.0)

It looks like there was a fix here, but almost two years later, I don't seem to have it. I don't know which version the fix went into.

Maybe I have an old version?

> packageVersion("dbplyr")
[1] ‘1.4.2’
> packageVersion("tidyverse")
[1] ‘1.3.0’

I tried dbplyr from the vanilla tidyverse install (1.3.0), then I also tried installing dbplyr from github:

devtools::install_github("tidyverse/dbplyr")

In both cases it looks like the numbers become float (numeric), and that makes Postgres (11) cranky in some other code I have:

Error in postgresqlExecStatement: RS-DBI driver: (could not Retrieve the result : ERROR:  function pg_catalog.substring(text, numeric, numeric) does not exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorfunc trans 🌍Translation of individual functions to SQL

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions