Dbplyr :: in_schema is case sensitive

The dbplyr :: in_schema () function cannot connect to uppercase tables.

When I create a table in PostgreSQL.

CREATE TABLE public."OCLOC"
(
  cod_ocloc double precision NOT NULL,
  lab_ocloc character varying(255),
  CONSTRAINT pk_ocloc PRIMARY KEY (cod_ocloc)
);

INSERT INTO public."OCLOC"(
            cod_ocloc, lab_ocloc)
    VALUES (1, 'example');

      

Then I try to connect to the table using in_schema from R:

 con <- DBI::dbConnect(RPostgreSQL::PostgreSQL(), 
                  dbname = 'dbname', 
                  user = 'user', 
                  host = 'host', 
                  password = 'password')

 tbl(con, dbplyr::in_schema('public','OCLOC'))

      

Warns about the next error

Error in postgresqlExecStatement(conn, statement, ...) : 
  RS-DBI driver: (could not Retrieve the result : ERROR:  no existe la relación «public.ocloc»
LINE 1: SELECT * FROM public.OCLOC AS "zzz3" WHERE 0=1
                  ^
)

      

But when I try without connecting to in_schema it works:

tbl(con, 'OCLOC')

      

Looks like a case insensitive problem. This creates a problem when I am using a database with schemas other than public and there are table names with capital letters.

+3


source to share


1 answer


I found the solution as follows: adding "inside"



tbl (con, '"OCLOC"')

0


source







All Articles