-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Add also() for query beans #3461
Comments
I've created a PR that uses An alternative would be to use the more specific The @Test
void also() {
var myPager = new MyPager(10);
var q = new QCustomer()
.select(name)
.also(myPager)
.query();
q.findList();
assertThat(q.getGeneratedSql()).contains("select /* QueryAlsoIfTest.also */ t0.id, t0.name from be_customer t0 limit 10");
}
static class MyPager implements Consumer<QueryBuilder<?,?>> {
final int maxRows;
MyPager(int maxRows) {
this.maxRows = maxRows;
}
@Override
public void accept(QueryBuilder<?, ?> queryBuilder) {
queryBuilder.setMaxRows(maxRows);
}
} |
I'm afraid (just like you explained) Another concern is that such signature would differ from But I also see now that in this case it's vice versa with Is there some solution to support both? Some kind of method overloading? Or two methods (like "also()" and "alsoApply()", i.e. stupid naming but on the other hand would do the job)? |
I'm thinking going with This might not be perfect vs adding some sort of generic |
Makes sense, thanks. |
Feature Request
Please add
also()
function (unconditional version ofalsoIf()
) into query beans. Example usage would be:Current Workaround
Hardcode
true
for conditionalalsoIf()
:Why
Better readability. Code reuse. It would be very convenient for applying group of conditions that form a single meaning, especially when such logic could be shared between multiple query bean creations.
Possible examples are:
The text was updated successfully, but these errors were encountered: