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

[Wiki] Possible wrong example in Statement Parameters section in documentation #557

Closed
heiwiper opened this issue Apr 3, 2022 · 3 comments

Comments

@heiwiper
Copy link

heiwiper commented Apr 3, 2022

When trying to generate dynamic statement parameters using pqxx::placeholders class, the documentation suggests starting a new parameter placeholder using next() function and then get the placeholder's string using get(). Calling these functions in this order generates the second placeholder instead of the first which throws an error later on when executing the SQL statement.

The correct usage would be to call get() and then next().

@jtv
Copy link
Owner

jtv commented Apr 3, 2022

You're right, thanks for pointing that out. Perhaps I should just scrap the placeholders class altogether. It probably complicates more than it simplifies, and there's always the risk of undefined behaviour if there's no sequence point between invocations.

@heiwiper
Copy link
Author

heiwiper commented Apr 3, 2022

I think it's quite helpful at least for my case, I am currently writing a code that converts a query in a specific protocol into SQL query in which the number of arguments changes, so using placeholder's class the way it's suggested in the website made it much easier for me since I don't know how many attributes the query contains.

@jtv jtv closed this as completed in 134f593 Apr 3, 2022
@jtv
Copy link
Owner

jtv commented Apr 3, 2022

Ah OK, if it's actually useful to people I guess that changes things. :-) Just fixed the example. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants