Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbQuoteLiteral #172

Closed
hadley opened this issue Apr 3, 2017 · 6 comments
Closed

dbQuoteLiteral #172

hadley opened this issue Apr 3, 2017 · 6 comments

Comments

@hadley
Copy link
Member

hadley commented Apr 3, 2017

Needs to convert:

  • integers
  • doubles (adding trailing .0, and handling Inf, -Inf)
  • logical
  • dates
  • date/times
  • strings
  • SQL strings

All need to convert NA to NULL.

Could replace dbQuoteString()

@hannes
Copy link
Contributor

hannes commented Apr 3, 2017

perhaps also raw/BLOB?

@krlmlr
Copy link
Member

krlmlr commented Apr 6, 2017

Should also preserve names (#173).

@krlmlr
Copy link
Member

krlmlr commented Nov 9, 2017

@hannesmuehleisen: Is the X'xxxx' syntax for BLOB literals sufficiently standardized to warrant inclusion in DBI?

    if (is.list(x)) {
      blob_data <- vapply(
        x,
        function(x) {
          if (is.null(x)) "NULL"
          else if (is.raw(x)) paste0("X'", paste(format(x), collapse = ""), "'")
          else {
            stop("Lists must contain raw vectors or NULL", call. = FALSE)
          }
        },
        character(1)
      )
      return(SQL(blob_data))
    }

@hannes
Copy link
Contributor

hannes commented Nov 9, 2017

The X is standardized (ISO/IEC 9075-2:2008(E)) at least in SQL 2008 which I have here. It also says both upper- and lowercase is ok.
screen shot 2017-11-09 at 16 27 27

@krlmlr
Copy link
Member

krlmlr commented Nov 9, 2017

Thanks!

@krlmlr krlmlr closed this as completed in 1b27260 Nov 9, 2017
@hadley
Copy link
Member Author

hadley commented Nov 10, 2017

FWIW I think SQL 2003 support is still kind of shaky, so it's quite possible that many databases won't support this. (But it's still fine to have in DBI)

krlmlr added a commit that referenced this issue Nov 27, 2017
- The deprecated `print.list.pairs()` has been removed.
- Fix `dbDataType()` for `AsIs` object (#198, @yutannihilation).
- Point to db.rstudio.com (@wibeasley, #209).
- Reflect new 'r-dbi' organization in `DESCRIPTION` (@wibeasley, #207).
- Using switchpatch on the second argument for default implementations of `dbQuoteString()` and `dbQuoteIdentifier()`.
- New `dbQuoteLiteral()` generic. The default implementation uses switchpatch to avoid dispatch ambiguities, and forwards to `dbQuoteString()` for character vectors. Backends may override methods that also dispatch on the second argument, but in this case also an override for the `"SQL"` class is necessary (#172).
- Fix `dbQuoteString()` and `dbQuoteIdentifier()` to ignore invalid UTF-8 strings (r-dbi/DBItest#156).
krlmlr added a commit that referenced this issue Mar 9, 2018
…ps the names from the output if the `names` argument is unset. - The `dbReadTable()`, `dbWriteTable()`, `dbExistsTable()`, `dbRemoveTable()`, and `dbListFields()` generics now specialize over the first two arguments to support implementations with the `Id` S4 class as type for the second argument. Some packages may need to update their documentation to satisfy R CMD check again. New generics ------------ - Schema support: Export `Id()`, new generics `dbListObjects()` and `dbUnquoteIdentifier()`, methods for `Id` that call `dbQuoteIdentifier()` and then forward (#220). - New `dbQuoteLiteral()` generic. The default implementation uses switchpatch to avoid dispatch ambiguities, and forwards to `dbQuoteString()` for character vectors. Backends may override methods that also dispatch on the second argument, but in this case also an override for the `"SQL"` class is necessary (#172). Default implementations ----------------------- - Default implementations of `dbQuoteIdentifier()` and `dbQuoteLiteral()` preserve names, default implementation of `dbQuoteString()` strips names (#173). - Specialized methods for `dbQuoteString()` and `dbQuoteIdentifier()` are available again, for compatibility with clients that use `getMethod()` to access them (#218). - Add default implementation of `dbListFields()`. - The default implementation of `dbReadTable()` now has `row.names = FALSE` as default and also supports `row.names = NULL` (#186). API changes ----------- - The `SQL()` function gains an optional `names` argument which can be used to assign names to SQL strings. Deprecated generics ------------------- - `dbListConnections()` is soft-deprecated by documentation. - `dbListResults()` is deprecated by documentation (#58). - `dbGetException()` is soft-deprecated by documentation (#51). - The deprecated `print.list.pairs()` has been removed. Bug fixes --------- - Fix `dbDataType()` for `AsIs` object (#198, @yutannihilation). - Fix `dbQuoteString()` and `dbQuoteIdentifier()` to ignore invalid UTF-8 strings (r-dbi/DBItest#156). Documentation ------------- - Help pages for generics now contain a dynamic list of methods implemented by DBI backends (#162). - `sqlInterpolate()` now supports both named and positional variables (#216, @hannesmuehleisen). - Point to db.rstudio.com (@wibeasley, #209). - Reflect new 'r-dbi' organization in `DESCRIPTION` (@wibeasley, #207). Internal -------- - Using switchpatch on the second argument for default implementations of `dbQuoteString()` and `dbQuoteIdentifier()`.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants