Skip to content

feat: dbUnquoteIdentifier() creates Id() objects without component names - #422

Merged
krlmlr merged 4 commits into
mainfrom
unquote
Dec 20, 2023
Merged

krlmlr merged 4 commits into
mainfrom
unquote

Conversation

@hadley

@hadley hadley commented Nov 10, 2023

Copy link
Copy Markdown
Member

Fixes #421

@hadley
hadley requested a review from krlmlr November 10, 2023 16:19
@aviator-app

aviator-app Bot commented Nov 10, 2023 •

Copy link
Copy Markdown
Contributor

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged manually (without Aviator). Merging manually can negatively impact the performance of the queue. Consider using Aviator next time.


See the real-time status of this PR on the Aviator webapp.

Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@krlmlr

krlmlr commented Nov 10, 2023

Copy link
Copy Markdown
Member

So, we're losing the names in the output of dbUnquoteIdentifier() ? I'll check how this and the current state of DBI is compatible with DBItest, perhaps we need to adapt there, or there are reasons why the behavior is the way it is now.

Could be that we lose (or have already lost) dbListObjects() functionality. We don't want to lose it because the IDE depends on it: https://github.com/rstudio/rstudio/blob/6b9436f529581d79c43abbea8cb08a0f6a3cdd60/src/cpp/session/modules/sql/SessionSql.R#L351.

@hadley

hadley commented Nov 11, 2023

Copy link
Copy Markdown
Member Author

Hmmmm, lets explicitly test for that, and maybe see if we can repair in dbListObjects() if needed.

@hadley

hadley commented Nov 13, 2023

Copy link
Copy Markdown
Member Author

Hmmm, it appears this only affects autocomplete (and I'm not sure in what context) so it might be ok to break temporarily. The cran github org seems to be down right now, but it looks like maybe only RMariaDB is the only dbListObjects() method to call dbiUnquoteIdentifier(). RPostgres assumes that prefix is an Id and RSQLite doesn't have a dbListObjects() method.

So all-in-all I think this is likely to be a low risk change.

@hadley

hadley commented Nov 14, 2023

Copy link
Copy Markdown
Member Author

But overall I think this is unlikely to cause problems for folks.

@krlmlr krlmlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Do we still need this right now, if the user has a way to create Id objects without naming the components? Why is it important that dbUnquoteIdentifier() returns unnamed Id objects?

How do you feel about making this opt-in, with a new named argument to dbUnquoteIdentifier() ? That would give me a little more peace of mind.

if (is(x, "SQL")) {
id_rx <- '(?:"((?:[^"]|"")+)"|([^". ]+))'
# Determine quoting character
quote_char <- substr(dbQuoteIdentifier(conn, ""), 1, 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we handle the case of brackets [] used for quoting?

if (is(x, "SQL") || is.character(x)) {
x <- lapply(x, unquote, quote_char = quote_char)
lapply(x, Id)
} else if (is(x, "Id")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be "UnnamedId" after #429.

@krlmlr krlmlr changed the title A more general strategy for unquoting feat: dbUnquoteIdentifier() creates Id() objects without component names Dec 20, 2023
@krlmlr
krlmlr merged commit 69f3ae3 into main Dec 20, 2023
@krlmlr
krlmlr deleted the unquote branch December 20, 2023 14:58
@krlmlr

krlmlr commented Dec 20, 2023

Copy link
Copy Markdown
Member

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update dbUnquoteIdentifier

2 participants