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

Upsert Support? #16

Closed
thomasmarsh opened this issue Sep 22, 2014 · 4 comments
Closed

Upsert Support? #16

thomasmarsh opened this issue Sep 22, 2014 · 4 comments

Comments

@thomasmarsh
Copy link

SQLite supports the "INSERT OR REPLACE" syntax for MERGE statements. It doesn't look like this is supported in sqlpp11. Are there plans to add this?

@rbock
Copy link
Owner

rbock commented Sep 23, 2014

On 2014-09-22 21:13, Thomas marsh wrote:

SQLite supports the "INSERT OR REPLACE" syntax for MERGE statements.
It doesn't look like this is supported in sqlpp11. Are there plans to
add this?


Reply to this email directly or view it on GitHub
#16.

As far as I can tell, INSERT OR REPLACE is not equivalent to MERGE
because it replaces ALL columns, not just those which are given in the
statement. Thus, INSERT OR REPLACE should be added to the sqlite connector.

That should be very simple, copy insert.h, move it into the sqlite3
namespace, replace the insert_t struct with an insert_or_replace struct
and add an insert_or_replace method. You might want to give that a try
(and send a pull request afterwards).

Otherwise, it will probably take a few more days :-)

Best,

Roland

@rbock
Copy link
Owner

rbock commented Sep 25, 2014

I just pushed a few commits to the develop branch of the sqlite3 connector. They give you insert_or_replace_into and insert_or_ignore_into, see tests/Sample.cpp (last two statements).

Please check and let me know.

@thomasmarsh
Copy link
Author

This looks good. Thank you for implementing that!

@rbock
Copy link
Owner

rbock commented Sep 30, 2014

Thanks for the request and the review.

It is the first extension of this kind. I am glad it worked out exactly as I had expected (and advertised at CppCon) :-)

@rbock rbock closed this as completed Sep 30, 2014
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