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

Confusing error for names in parameterized queries #266

Closed
mbedward opened this issue Nov 4, 2020 · 2 comments
Closed

Confusing error for names in parameterized queries #266

mbedward opened this issue Nov 4, 2020 · 2 comments
Labels
Milestone

Comments

@mbedward
Copy link

mbedward commented Nov 4, 2020

This is perhaps related to #199 but hopefully a simpler request.

Presently this code...

dat <- data.frame(foo = 1:3, bar = 4:6)
rs <- dbSendQuery(con, "INSERT INTO sometable (foo, bar) VALUES ($1, $2);")
dbBind(rs, params = dat)
dbClearResults(rs)

...provokes an error: 'Named parameters not supported'.

This confused me because the code has positional rather than named placeholders. After looking at the package sources (PgResult.R line 172) I arrived at this work-around:

dbBind(rs, params = unname(dat))

Would it cause problems if names were just ignored rather than raising an error? If so, perhaps adding an example of this work-around to the docs would help others.

@krlmlr
Copy link
Member

krlmlr commented Dec 26, 2020

Thanks. I agree the error message could be clearer. What wording would be best suited for the problem?

The strictness here is intentional -- named placeholders require named parameters, same with unnamed.

@krlmlr krlmlr added this to the 1.2.2 milestone Dec 26, 2020
@krlmlr krlmlr added the docs label Dec 27, 2020
@krlmlr krlmlr modified the milestones: 1.2.2, 1.2.3, 1.4.0 Jan 2, 2021
@krlmlr krlmlr closed this as completed in 29e49d7 Sep 14, 2021
@github-actions
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 Sep 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants