0.9.6 is out and it includes the final pieces for expressions.
Expressions are designed to cover the harder comparisons that QDT.permittedValues methods don't cover.
They are inspired by the Java 8 stream framework so every expression method produces a new expression. This sounds complicated but it's a well known technique and easy to write code with.
To start an expression use the DBRow column( ) method or the appropriate Expressions value( ) method. After that the methods you can use will be available to you:
marq.column(marq.uidMarque).plus(2).minus(4).bracket().times(6).bracket().dividedBy(3)
The column method creates a expression appropriate to the field, in this case a NumberExpression, and each method call creates a new expression of the appropriate class.
To add the above expression to your DBQuery you'll need to get a BooleanExpression as every condition is a test between 2 or more expressions. The above expressions is included in the test as:
marq.column(marq.uidMarque).plus(2).minus(4).bracket().times(6).bracket().dividedBy(3).is(-2));
To use the expression drop it into the addCondition() method in DBQuery.
Some expressions start with a literal value and the best way to get the expression is to use the static value method provide in each of the expression classes
StringExpression.value("V").append(nameValue.replace("BMW","")
NumberExpression.value(5).divideBy(marque.column(marque.uidMarque))
DateExpression.value(lastTuesday).is(marque.column(marque.creationDate))
Expressions also provide access to the builtin functions like CURRENT_USER and SYSDATE. They are available as static methods on the expression class similar to their return type.
marq.name.permittedValues(StringExpression.currentUser());
The last example also shows you can use expressions with QDTs directly.
JavaDocs have been improved for all of the nz.co.gregs.dbvolution classes. It felt like a herculean effort and produced several process and bug fixes, so I hope they're good :)
Anonymous