np-hard
np-hard

Reputation: 5815

expanding jooq's row value query

Using jooq to generate query for MySQL and checking if the row value clause generated by it can be expanded since mysql is not able to use indexes properly in row value queries

for example

DSLContext context = new DefaultDSLContext(SQLDialect.MYSQL);
SelectQuery<Record> select = context.selectQuery();
select.addSelect(field("Col1"));
select.addFrom(table("Table1").as("T1"));
select.addOrderBy(field("Name"), field("Sid"));
select.addSeekAfter(param("p2", "John"), param("p3","123"));
String generated = select.getSQL(ParamType.NAMED);

produces following query

where (1 = 1 and (Name, Id) > (:p2, :p3)) order by Name asc, Id asc

but will like to be

where Name > :p2 or (Name = :p2 and Id > :p3) order by Name asc, Id asc

Upvotes: 1

Views: 59

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 221350

It's currently (jOOQ 3.9, see #6230) not possible to override this behaviour. You'll have to add an explicit predicate of the form you'd like it to be.

Upvotes: 1

Related Questions