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

dbQuoteIdentifier() ignores names given to Id(), uses arguments in order #383

Closed
pnacht opened this issue Mar 3, 2022 · 4 comments · Fixed by #427
Closed

dbQuoteIdentifier() ignores names given to Id(), uses arguments in order #383

pnacht opened this issue Mar 3, 2022 · 4 comments · Fixed by #427
Labels

Comments

@pnacht
Copy link

pnacht commented Mar 3, 2022

See the reprex below. dbQuoteIdentifier() is called twice with the same table data. All that changes is the order in which the Id() arguments were given. Conceptually, this should be irrelevant and return the same identifier, but it's changed. Clearly dbQuoteIdentifier() is ignoring the names given to Id() and simply using the order in which they are defined.

packageVersion("DBI")
#> [1] ‘1.1.2’

packageVersion("odbc")
#> [1] ‘1.3.3’

conn <- DBI::dbConnect(
  # an odbc connection to SQL Server
)

name <- DBI::Id(catalog = "db", schema = "schema", table = "tbl")
DBI::dbQuoteIdentifier(conn, name)
#> <SQL> "db"."schema"."tbl"

# same name, but switching order of arguments
name <- DBI::Id(schema = "schema", catalog = "db", table = "tbl")
DBI::dbQuoteIdentifier(conn, name)
#> <SQL> "schema"."db"."tbl"

DBI::dbDisconnect(conn)

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

This is especially odd given that Id() demands that all its arguments be named. Given that Id() is likely only ever used as an argument to dbQuoteIdentifier() (even if via other functions which eventually call it), it seems odd that the user is forced to define names which aren't actually used.

@tentacles-from-outer-space

And names mean nothing

packageVersion("DBI")
#> [1] '1.1.3'
name <- DBI::Id(blah = "element_1", another_blah = "element_2", final_blah = "element_3")
DBI::dbQuoteIdentifier(DBI::ANSI(), name)
#> <SQL> "element_1"."element_2"."element_3"

Created on 2022-11-18 with reprex v2.0.2

@krlmlr
Copy link
Member

krlmlr commented Nov 19, 2022

Huh, missed that. This is clearly wrong, thanks for reporting.

@krlmlr
Copy link
Member

krlmlr commented Dec 17, 2023

Fixed in dev.

@krlmlr krlmlr closed this as completed Dec 17, 2023
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants