Skip to content

Conversation

jeffgbutler
Copy link
Member

This also removes the incrementBy, decrementBy, etc. operations as they
are replaced by more flexible alternatives.

This also removes the incrementBy, decrementBy, etc. operations as they
are replaced by more flexible alternatives.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling af417bd on jeffgbutler:master into 549c458 on mybatis:master.

@tnicolas29200
Copy link

Hello,

it's interesting. It standardizes the use of arithmetic operations in queries.

Unfortunately, it is still not possible to use dynamic values (or i don't see how to do that).

With your implementation, you can't have something like :
UPDATE table SET field = field + xxx

where xxx is a dynamic value, like 1 or 3 or 15000.

You can just write 1 class per constants, so you must use a constant of the operand at design time and not passing a variable value.
I need to be able to parameterize a query with a dynamic value not recovered from a subquery or another field

@jeffgbutler
Copy link
Member Author

You could write a generic function like this

    private UpdateStatementProvider generateUpdate(Integer _id, Integer factor) {
        return update(foo)
                .set(bar).equalTo(multiply(bar, constant(factor.toString())))
                .where(id, isEqualTo(_id))
                .build()
                .render(RenderingStrategy.MYBATIS3);
        
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants