Skip to content

No TRUE literal in SQL Server, should escape() default to list(clause = "SELECT") ? #934

Description

@krlmlr

MSSQL has no TRUE literal, but it's returned from translations: https://stackoverflow.com/a/7171264/946850.

dm uses a home-grown routine to insert records into MS SQL Server, via dbplyr::escape() . This breaks with dbplyr >= 2.2.0.

The reprex illustrates the problem. What's a good solution?

library(dbplyr)

con <- simulate_mssql()

# Buggy, no TRUE literal: https://stackoverflow.com/a/7171264/946850
escape(TRUE, con = con)
#> <SQL> TRUE

# This is what dm needs:
escape(c(TRUE, FALSE), parens = FALSE, collapse = NULL, con = con)
#> <SQL> TRUE
#> <SQL> FALSE

# Still buggy:
translate_sql_(list(TRUE), con = con)
#> <SQL> TRUE

# Correct, but how to achieve for a vector?
translate_sql_(list(TRUE), con = con, context = list(clause = "SELECT"))
#> <SQL> 1

# Useless for dm:
translate_sql_(list(c(TRUE, FALSE)), con = con, context = list(clause = "SELECT"))
#> <SQL> (1, 0)

Created on 2022-07-06 by the reprex package (v2.0.1)

CC @TSchiefer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions