Is there a dsl for parenthesis?


#1

when using or condition, parenthesis needed.
currently i am using concatenating.
x(" (" + path("t", "name").eq(s("aaa")).or( path("t", "name").eq(s("aaa"))) + ") ")
is there a dsl method?
like this.
x( paren (path("t", "name").eq(s("aaa")).or( path("t", "name").eq(s("aaa")))))


#2

There’s the sub method on Expression. It was initially intended for subselect clauses but works for that use case as well since it just surrounds any Expression in parenthesis.


#3

sub method is not for expression but for statement. is there a method for expression?


#4

ah my bad you’re right it’s taking a Statement. So no, there’s no dedicated method in the DSL to wrap in parenthesis.


#5

ok. i see.
thanks a lot.


#6

You should really consider adding this feature, ran into the same problem and now use something like:

Expression.x("(" + expression.toString() + ")")

looks ugly to my eyes.


#7

You’re right, a bit ugly.
I created the par() method in Expression for that, see https://issues.couchbase.com/browse/JCBC-960
That will be in 2.3 :smile:


#8

Cool, thanks. Will 2.3 be available for the community edition?


#9

yeah, in general the SDKs don’t have any particular restriction in regards to community vs enterprise editions of the server (as in, they’ll adapt to what you have)