Implement insert_or_replace - #45
liuzicheng1987 merged 23 commits into
Conversation
|
Hi @demianmnave , this is pretty cool! I'd like to find a solution for PostgreSQL and MySQL as well. I'd be happy to contribute tot this PR. |
|
@demianmnave , two things:
|
|
Hi @liuzicheng1987,
It should already be removed in the second commit, d21b9d9.
Yes, totally missed it. I can look into it unless you get to it first.
Looking deeper into the docs, The ramifications of implementing |
|
As far as the primary key is concerned, I will take care of it, the push will come tonight. I think as long as the outcome is the same, it doesn't matter too much to me whether the row is replaced or updated. I think we will just have to live with the fact that these kind of implementation details will differ from database to database. |
|
@liuzicheng1987 Thanks for looking into the primary key fix. If you would like to bring this PR home, I can look into MySQL and PostgreSQL separately. Also, I can update the docs to make it clear that a primary key or unique index is needed for |
|
@demianmnave , here are compile time checks for primary keys. |
|
@demianmnave , the way I would approach this for Postgres is the following: https://www.sparkcodehub.com/sql/data-manipulation/on-conflict-clause It means we would have to add an additional field, non_primary_keys, to For MySQL, the idea is the same, just a bit of a different syntax. https://www.geeksforgeeks.org/mysql/upsert-in-mysql/ |
|
@demianmnave for your convenience, I have added the field I will leave the rest to you. Again - thank you for this contribution. This is very cool and I look forward to using it. |
|
@liuzicheng1987 Great, thanks for pointing me in the right direction. |
|
@liuzicheng1987 I believe the is ready to go. The latest commits implement I ran the full battery of unit tests for MSVC 17.14.12 under Windows 11 against the following database versions:
All unit tests passed except for Let me know if you spot anything amiss and I will get it corrected ASAP. |
|
@demianmnave , all right, I have merged this. Thank you so much for the contribution! |
|
@liuzicheng1987 Thank you, and apologies for the unnecessary busy work. The one change that may need some investigation is the removal of explicitly setting CMAKE_MSVC_RUNTIME_LIBRARY. Without this, sqlgen fails to build when using the vcpkg x64-windows-static triplet due to conflicting runtime libraries. |
|
@demianmnave I had the opposite experience: The build pipelines only worked after I removed it. |
|
@demianmnave but feel free to open a separate PR. If we can find a way that works for you and the build pipelines, that would be the best solution. |
|
@liuzicheng1987 Will do. |
This update provides an unsophisticated implementation of the SQLite
INSERT OR REPLACEstatement.