Conversation
|
I just added functions to handle #533 but I'm getting a linker error with the unit tests. I need to sleep now but I can try and figure out what's going on with the unit test builds over the weekend. |
|
@jagerman , in order to maintain ABI compatibility and avoid the compiler errors that come with the ambiguity of To clarify, the linker error was caused by the library being compiled with an older C++ standard than the tests... which is something that we probably want to support. |
explanation: SRombauts#518 (comment) Also I fixed indentation on some documentation comments.
|
Just pushed those changes. @SRombauts, does this look like something you think would make sense for the project? If not, please let me know and I'll close the PR. |
I know you didn't ask me, but personally I find this PR highly valuable: currently this library has no ability to bind TEXT values into statement placeholders without copying, which feels like a big omission versus the C API, which allows this easily. I tried to work around the limitation by seeing if I could get the raw C API statement handle out of a SqliteCpp::Statement so that I could bind such values myself via the C API, but that proved impossible: Statement's internal handle is private and thus entirely inaccessible and so my choices were either: 1) avoid SQLite::Statement entirely and use the C API for all binding if I want to be able to do copy-less TEXT binding; 2) give up and just accept unnecessary copying; 3) fork the project to add it. I opted for 3, but luckily found this PR already written and so am currently building on a fork with this merged. (The key changes here are much less important, because Database does expose the C handle, so there it's pretty simple to just go to the C API for that one call). |
I'm not sure if you would actually want to do this here or not, but one way to avoid that ambiguity is to define a C literal overload as well: It is starting to feel a bit heavy though, and the pointer+size version would be perfectly fine for me. |
|
Agreed, but this library has been around for a while and idk how enthusiastic maintainers are about new features here. I forgot that's an option. I personally like the pointer+len approach more because otherwise I'd have to convert my custom secure string type to |
|
@SRombauts bump |
|
Hey @dvtate, thanks a lot for the proposal and the bump! I am sorry for the long delay, but sadly the PR was opened at a time when I was in vacation, the subject was too complex to wrap my head around, and then life happened 😓 Now, on the implementation, I see a few important issues that we should address before merging:
Let me know if you are willing to handle that, I would understand if it's too much work, esp. given how unresponsive I have been. Sébastien |
Unless something comes up, I should have enough free time this week. Knocking out 1-3 should be straightforward. For 4, Because Given that this is a minor, performance-oriented feature, vacation should definitely take priority IMO. Glad to see you're back tho :) |
|
Ok, I re-based my changes on master. I'm seeing now that the library is built with C++11 so the string view methods don't get compiled. To avoid changing that I'll have to add in some C++11-compatible helper methods to isolate std::string_view to the headers. |
|
And there is the compatibility issue I was talking about: mixing c++11 & c++17. We want to be able to build the lib in one version, and use it in multiple clients with different version Something that we should do for (or before) this task is adding a few of CI config to test :
In summary, it would mean perhaps just building 2 "consumers" apps with different c++ levels, to prevent any regression. |
|
Unrelated, but, But be careful with empty values: |
Added that in commit. I added some private With this change, the library can be built with C++11 and used with C++17 users. It appears the tests are built with C++17 as I'm seeing my string_view tests (within macros) passing. It appears that |
|
Thanks a lot for your hard work, I see that the CI is failing... I am going to review all that asap, either tonight or tomorrow. I am actually considering removing support for C++11: I should release one last version and upgrade SQLiteCpp to a new version 4.0.0 with a more recent CMake requirement to support C++17 as the baseline! This should make these changes simpler, and could help us modernize and simplify the codebase |
This adds a small consumer application to check the supported C++ standard combinations. The CI covers: - C++11 library / C++11 consumer - C++11 library / C++17 consumer - C++17 library / C++17 consumer The C++17 consumer already exercises the existing `std::filesystem::path` API. This gives us a place to add `std::string_view` coverage from #518 without requiring the library itself to be built as C++17.
|
Oops, looking at the CI logs I forgot to put the column tests behind c++17 macros. I'll fix that. |
👍 on this idea: C++11 is pretty ancient at this point and C++17 is more or less available everywhere and brings a lot of nice language and STL improvements. |
|
Or to put it another way:
That was 8 years 11 months after C++11 finalized. C++17 finalized 9 years 6 months ago. (And this makes me feel old). |
That's not UB: that's exactly what a default-constructed string_view does. (It's construction from a nullptr without a size, or with a non-zero size, that are UB). |
|
Yea, as long as C++11 projects can still use the library it should be fine. C++11 is like Java 8 -- many are afraid to bump the number even if they don't have to use any of the new features. Assuming the library and consumer are using the same/similar compilers everything should be fine afaik. |
Agreed that there's no reason for it to be UB but cppreference had some spooky wording and I'm not a language lawyer.
From what I'm seeing online, This SO thread suggests that it's not UB but a lot of the sources they reference relate to So it's probably safe to remove the check. Unless there's a remote possibility that |
|
Regarding the potential UB I was referring to, the confusion was coming from the following: So you can just forget about it 🙏 |
|
I have been trying to do a thorough review of your code changes, that looks good overall, but I have had a few questions to dig deeper (including on some of my own codes that I couldn't remember why it was changed later, namely in |
|
Because of the code there I assumed I couldn't do int len = getBytes();
return std::string_view((const char*) getBlob(), len);Take your time reviewing. |


My goal is to fix this issue: #517
Previous, similar PRs:
I should probably add unit tests and examples using string_view.