Search in sources :

Example 6 with IncludeIn

use of com.querydsl.core.testutil.IncludeIn in project querydsl by querydsl.

the class InsertBase method uuids.

@Test
@IncludeIn({ H2, POSTGRESQL })
@SkipForQuoted
public void uuids() {
    delete(QUuids.uuids).execute();
    QUuids uuids = QUuids.uuids;
    UUID uuid = UUID.randomUUID();
    insert(uuids).set(uuids.field, uuid).execute();
    assertEquals(uuid, query().from(uuids).select(uuids.field).fetchFirst());
}
Also used : UUID(java.util.UUID) Test(org.junit.Test) IncludeIn(com.querydsl.core.testutil.IncludeIn)

Example 7 with IncludeIn

use of com.querydsl.core.testutil.IncludeIn in project querydsl by querydsl.

the class InsertBase method insert_with_special_options.

@Test
@IncludeIn(MYSQL)
@SkipForQuoted
public void insert_with_special_options() {
    SQLInsertClause clause = insert(survey).columns(survey.id, survey.name).values(3, "Hello");
    clause.addFlag(Position.START_OVERRIDE, "insert ignore into ");
    assertEquals("insert ignore into SURVEY (ID, NAME) values (?, ?)", clause.toString());
    assertEquals(1, clause.execute());
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause) Test(org.junit.Test) IncludeIn(com.querydsl.core.testutil.IncludeIn)

Example 8 with IncludeIn

use of com.querydsl.core.testutil.IncludeIn in project querydsl by querydsl.

the class TargetRule method isExecuted.

private boolean isExecuted(Description description, Target target) {
    ExcludeIn ex = description.getAnnotation(ExcludeIn.class);
    // excluded in given targets
    if (ex != null && Arrays.asList(ex.value()).contains(target)) {
        return false;
    }
    // included only in given targets
    IncludeIn in = description.getAnnotation(IncludeIn.class);
    if (in != null && !Arrays.asList(in.value()).contains(target)) {
        return false;
    }
    return true;
}
Also used : IncludeIn(com.querydsl.core.testutil.IncludeIn) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 9 with IncludeIn

use of com.querydsl.core.testutil.IncludeIn in project querydsl by querydsl.

the class SelectOracleBase method sumOver.

@Test
@IncludeIn(ORACLE)
@SkipForQuoted
public void sumOver() throws SQLException {
    //        SQL> select deptno,
    //        2  ename,
    //        3  sal,
    //        4  sum(sal) over (partition by deptno
    //        5  order by sal,ename) CumDeptTot,
    //        6  sum(sal) over (partition by deptno) SalByDept,
    //        7  sum(sal) over (order by deptno, sal) CumTot,
    //        8  sum(sal) over () TotSal
    //        9  from emp
    //       10  order by deptno, sal;
    expectedQuery = "select e.LASTNAME, e.SALARY, " + "sum(e.SALARY) over (partition by e.SUPERIOR_ID order by e.LASTNAME asc, e.SALARY asc), " + "sum(e.SALARY) over (order by e.SUPERIOR_ID asc, e.SALARY asc), " + "sum(e.SALARY) over () from EMPLOYEE e order by e.SALARY asc, e.SUPERIOR_ID asc";
    oracleQuery().from(employee).orderBy(employee.salary.asc(), employee.superiorId.asc()).select(employee.lastname, employee.salary, SQLExpressions.sum(employee.salary).over().partitionBy(employee.superiorId).orderBy(employee.lastname, employee.salary), SQLExpressions.sum(employee.salary).over().orderBy(employee.superiorId, employee.salary), SQLExpressions.sum(employee.salary).over()).fetch();
    // shorter version
    QEmployee e = employee;
    oracleQuery().from(e).orderBy(e.salary.asc(), e.superiorId.asc()).select(e.lastname, e.salary, SQLExpressions.sum(e.salary).over().partitionBy(e.superiorId).orderBy(e.lastname, e.salary), SQLExpressions.sum(e.salary).over().orderBy(e.superiorId, e.salary), SQLExpressions.sum(e.salary).over()).fetch();
}
Also used : QEmployee(com.querydsl.sql.domain.QEmployee) Test(org.junit.Test) IncludeIn(com.querydsl.core.testutil.IncludeIn)

Example 10 with IncludeIn

use of com.querydsl.core.testutil.IncludeIn in project querydsl by querydsl.

the class MergeBase method mergeBatch_templates.

@Test
@IncludeIn(H2)
public void mergeBatch_templates() {
    SQLMergeClause merge = merge(survey).keys(survey.id).set(survey.id, 5).set(survey.name, Expressions.stringTemplate("'5'")).addBatch();
    merge.keys(survey.id).set(survey.id, 6).set(survey.name, Expressions.stringTemplate("'6'")).addBatch();
    assertEquals(2, merge.execute());
    assertEquals(1L, query().from(survey).where(survey.name.eq("5")).fetchCount());
    assertEquals(1L, query().from(survey).where(survey.name.eq("6")).fetchCount());
}
Also used : SQLMergeClause(com.querydsl.sql.dml.SQLMergeClause) Test(org.junit.Test) IncludeIn(com.querydsl.core.testutil.IncludeIn)

Aggregations

IncludeIn (com.querydsl.core.testutil.IncludeIn)11 Test (org.junit.Test)9 SQLMergeClause (com.querydsl.sql.dml.SQLMergeClause)4 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)2 SQLInsertClause (com.querydsl.sql.dml.SQLInsertClause)2 QEmployee (com.querydsl.sql.domain.QEmployee)1 QSurvey (com.querydsl.sql.domain.QSurvey)1 UUID (java.util.UUID)1