Conversation
|
I also have no clue, why here 3 commits are showing up. I am used to gitlab which handles git differently. I will clean up later. |
|
@MeanSquaredError Can you have a look here? I found finally some time to make a first attempt. You can see all in the third commit. The test is still messed up. |
|
Thanks for the PR, I will try to take a look at it shortly!
I think that you could try rebasing your branch against the latest main branch, e.g. This should synchronize the first two commits with the main branch and after the push they should disappear from this PR. |
|
OK, I rebased your branch on top of the latest main branch and then tried playing a bit with the I think it is OK to have the support for I wrote a basic build script + a very basic test program, which I will provide below in order to let everyone do the testing themselves. build.sh The actual test program, mytest.cpp The three commented-out lines correspond to three valid You can test each of them by removing the comment from the corresponding line in the source code. Although valid SQL, the first two compile but generate invalid SQL at runtime This is the first ( This is the second ( The third one doesn't compile with I think that the main problem with the current implementation is that the type of the column order expression ( The actual enabling/disabling of the methods can be done either through template specialization or through C++20 requires clauses attached to the corresponding methods. The approach with requires clauses seems easier to me, but I guess you need to try it to see whether it is simpler indeed. Maybe @rbock could chime in and let us know if my proposed design seems OK to him, or maybe he can think of a better approach. |
|
Thanks for the PR and the discussion so far. I am a bit pressed for time, but quickly: Disallowing nulls_first in the MySQL connector: asc/desc and nulls_first/last: And then it is rather straight forward:
Hope this makes sense? Cheers, |
|
@rbock |
like asc or desc can be more spefied via nulls first or last.
|
|
||
| template <typename L> | ||
| struct sort_order_expression { | ||
| constexpr sort_order_expression(L l, sort_type r) |
There was a problem hiding this comment.
It's better to keep the old parameter names (l and r) and not rename them unless it is really required. This will decrease the PR size and will simplify the PR review.
|
Looks good so far! |
|
Hey @SimpleForest , thanks for the next iteration! I left a bunch of comments. Beyond that, please add
|
| sort_order_expression& operator=(sort_order_expression&&) = default; | ||
| ~sort_order_expression() = default; | ||
|
|
||
| constexpr auto nulls_first() -> sort_order_with_nulls_expression<L>; |
There was a problem hiding this comment.
Please stay aligned with the library style (functions are defined inline).
|
|
||
| private: | ||
| friend reader_t; | ||
| const sort_order_expression<L> _lhs; |
There was a problem hiding this comment.
Please don't use const for the members.
These are private data members. Making them const does make the API any better.
But it could hurt if someone wanted to use copy or move assignment.
Also (general recommendation), it pays off to follow patterns of the existing code, e.g. for readability.
It might be perfectly fine to change the coding style, to introduce new patterns, etc, but that should happen in separate refactoring CLs.
| return ::sqlpp::order(std::forward<Expr>(self), t); | ||
| } | ||
|
|
||
| template <typename Expr> |
There was a problem hiding this comment.
This would go away, right? nulls_first and friends would only make sense in an order_expression.
| return {std::move(l), order}; | ||
| } | ||
|
|
||
| enum class nulls_pos { |
There was a problem hiding this comment.
This should go to sort_order_expression.h now
| last, | ||
| }; | ||
|
|
||
| template <typename L> |
There was a problem hiding this comment.
These should be dropped given the changes to sort_order_expression.
| requires(values_are_comparable<L, L>::value) | ||
| constexpr auto asc(L l) -> sort_order_expression<L> { | ||
| return {l, sort_type::asc}; | ||
| return {std::move(l), sort_type::asc}; |
There was a problem hiding this comment.
Once you undo the other changes in this file, these would stand out as unrelated refactoring.
These are good, but should go into a separate PR.
Hello,
please let me know what you think of the general approach.