rafafrdz / criteria4s

Criteria4s is a simple domain-specific language (DSL) to define criteria and predicate expressions for any data stores by using Scala type class mechanisms in a type-safe way. It pretends to be agnostic to any data store, and it is extensible to support any kind of data stores.
Apache License 2.0
16 stars 1 forks source link

Associative patterns in SQL exprssions #9

Closed rafafrdz closed 2 months ago

rafafrdz commented 2 months ago

If you use a sub-type of SQL criteria tag, for a simple expression like col[T]("id") === lit(1) you got the following representation: (id = '1'). However, if you inject that expression after a where sql, like s"WHERE ${col[T]("id") === lit(1)}" you will get WHERE (id = '1'), and its will fail.

The problem is that you just use parenthesis when needs to operate two predicates by using a conjunction operator (or /and).