-
Notifications
You must be signed in to change notification settings - Fork 346
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
[Feedback Requested] Results returning optional, string_view, and span #570
Comments
Forgot to mention: If you want to get your hands dirty and play with code, try out |
@rbock |
Thanks for the feedback and the question: That would be a breaking change |
@rbock Regarding the support for
Also I assume nullable text columns will be represented by |
Regarding the dynamic queries, just like everyone else I try to avoid them and only use them when static queries would cause too much code duplication :-) Overall depending on the project, dynamic queries are somewhere in the range of 2-5% of all sqlpp queries in my code. So a breaking change in the dynamic queries in not a major issue for me. However I just want to confirm - does this change mean that the old way of adding fields to query clauses will not longer work? That is there would be no way to add select fields in a separate
This is not a big issue, but I want to clarify that issue. |
Thanks for the detailed feedback!
It might be destroyed with the row or with the result, it depends on the database backend. The safe strategy would be to assume destruction with the row.
That is correct. |
OK, this is what I assumed too. It probably makes sense to document this behavior because I am pretty sure that this question will be asked again and again.
OK, I think that at least in my case it is relatively easy to adjust my code to the new syntax. I am really happy with the new std/sqlpp containers because they will make the users' code much simpler and more straightforward. This weekend I will try modifying and building one of my bigger projects with the new sqlpp and will report any success, issues and/or suggestions. |
Everything sounds good. I think our code base uses dynamic queries more than they should which will make adoption a bit harder. But I would not let breaking changes stand in the way of better/cleaner code. And if it means a clearer path to something like sqlpp17/20/23 then it is a step worth taking. Maybe consider releasing version 1.0 before the change and then this would become version 2.0. |
Thanks for mentioning the release version. I'll certainly think about it. I wonder how the transition would work? There is a release called 1.0, but how would the somewhat experimental code be called before marking 2.0? Keep it in the current branch? Call it 2.alpha.? |
I have no experience with releasing public libraries but I can imagine keeping the work in a |
One option would be:
Once the Or maybe don't version the development branch and just have one
In the above example the |
Thanks for the suggestions! @MeanSquaredError That's very close to the gitflow model, IIUC. My life's much easier since I dropped that in favor of just one main branch :-) It is not super urgent. It will take a few weeks at least before all of the above is done. For the time being, there will be main and optional. |
OK, tried the Building sqlpp + tests (core, postgresql, mysql, sqlite) with Then I tried building one of my pet projects with the new sqlpp. The project builds in c++23 mode with all warnings ( Now about the problems that I noticed. sqlpp11-ddl2cpp seems to generate incorrect definitions for postgresql primary fields by marking them as nullable, even though they are not. For example, I have the following database definition:
The generated header looks like this:
So the field I guss it is more of a bug in sqlpp11-ddl2cpp and the switch to Also I noticed that the compat versions of |
@MeanSquaredError Your investigations are really useful and inspiring. I will also try to use the new branch in the coming week if possible. So I wrote a long response on how PRIMRAY KEY does not imply primary key, then went on to test and indeed you are correct, also according to the docs:
|
@CJCombrink If I remember correctly the SQL standard requires any PRIMARY KEY column to be NOT NULL. However I don't have the standard handy, so I cannot quote the relevant part. From my observations pretty much any SQL database enforces this requirement, except for sqlite which as usual lives in a world of its own. |
Thanks for playing with the optional branch and the detailed feedback, @MeanSquaredError !
My local branch is a bit further along, I knocked away all dynamic code and started to remove quite some additional fluff in the clauses which became superfluous now. I'll upload as soon as tests compile again. The next step would then be to add optional columns, joins, expressions (probably in that order). |
Thanks, will come with the next upload. |
Added a new branch:
Next I'll look into adding optional columns (or additional cleanup potential). |
@rbock Then I tried building one of my personal projects with the new sqlpp. It seems that it has a problem assigning an
The function This is the relevant part of the database model generated by dll2cpp:
I am not sure if this information is sufficient, so if you want, I can prepare a minimal example tomorrow. |
Thanks for testing. And sorry, I apparently should have said this clearer: This new branch is strictly less than the Adding support for using optional in queries is yet to come (but it will be much easier after this cleanup). |
OK, thanks for the clarification! No hurry - the current stable version works great and I am pretty sure that the new version will be even better. If you need more testing for your work-in-progress, just post an update here and I will test it again. |
Hi,
I would love to get your feedback on this:
Triggered by #568 I started back porting some aspects of sqlpp17, in particular for SELECT result rows.
(std|sqlpp)::optional
.(std|sqlpp)::sting_view
.(std|sqlpp)::span<uint8_t>
.Assuming positive feedback, I would expand the use of these types similar to how they are used in sqlpp17. The most drastic change would be to express dynamic queries with optional query parts, e.g.:
would become something like
with
expression.if_(bool condition)
being equivalent tocondition ? sqlpp::make_optional(expression) : sqlpp::nullopt
.What do you all think?
Thanks,
Roland
The text was updated successfully, but these errors were encountered: