Zouyiu Ng (JoeWoo)
05/13/2024, 11:52 AMChantal Loncle
05/13/2024, 6:03 PMQuery
and override its `prepareSQL()`:
class HintQuery(
val hint: String,
set: FieldSet,
where: Op<Boolean>?
) : Query(set, where) {
override fun prepareSQL(transaction: Transaction, prepared: Boolean): String {
return "/*$hint*/ ${super.prepareSQL(transaction, prepared)}"
}
}
// adjust signature (and selectAll(), select()) depending on how high you want to chain
fun Query.hint(hint: String): HintQuery = HintQuery(hint, set, where)
TestTable
.selectAll()
.where { TestTable.amount greaterEq 100 }
.hint("FORCE_MASTER")
.toList()
If the hint needs to actually be in a different location or on a different statement type, please confirm with an example of the full expected final result, so I can take a look.Zouyiu Ng (JoeWoo)
05/15/2024, 1:13 AMHintQuery
except set
and where
, due to not copying properties from original query. Neither copy()
nor copyTo()
method are not available for calling. I'm making a PR to let extending Query
easier.Zouyiu Ng (JoeWoo)
05/22/2024, 5:03 PM