Search in sources :

Example 31 with ExcludeIn

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

the class TypesBase method dump_types.

@Test
@ExcludeIn({ CUBRID, POSTGRESQL, TERADATA })
public void dump_types() throws SQLException {
    Connection conn = Connections.getConnection();
    DatabaseMetaData md = conn.getMetaData();
    // types
    ResultSet rs = md.getUDTs(null, null, null, null);
    try {
        while (rs.next()) {
            // cat, schema, name, classname, datatype, remarks, base_type
            String cat = rs.getString(1);
            String schema = rs.getString(2);
            String name = rs.getString(3);
            String classname = rs.getString(4);
            String datatype = rs.getString(5);
            String remarks = rs.getString(6);
            String baseType = rs.getString(7);
            System.out.println(name + " " + classname + " " + datatype + " " + remarks + " " + baseType);
            // attributes
            ResultSet rs2 = md.getAttributes(cat, schema, name, null);
            try {
                while (rs2.next()) {
                    // cat, schema, name, attr_name, data_type, attr_type_name, attr_size
                    // decimal_digits, num_prec_radix, nullable, remarks, attr_def, sql_data_type, ordinal_position
                    // ...
                    String cat2 = rs2.getString(1);
                    String schema2 = rs2.getString(2);
                    String name2 = rs2.getString(3);
                    String attrName2 = rs2.getString(4);
                    String dataType2 = rs2.getString(5);
                    String attrTypeName2 = rs2.getString(6);
                    String attrSize2 = rs2.getString(7);
                    System.out.println(" " + attrName2 + " " + dataType2 + " " + attrTypeName2 + " " + attrSize2);
                }
            } finally {
                rs2.close();
            }
        }
    } finally {
        rs.close();
    }
}
Also used : Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 32 with ExcludeIn

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

the class UnionBase method union5.

// FIXME for CUBRID
// Teradata: The ORDER BY clause must contain only integer constants.
@SuppressWarnings("unchecked")
@Test
@ExcludeIn({ DERBY, CUBRID, FIREBIRD, TERADATA })
// FIXME
@Ignore
public void union5() {
    /* (select e.ID, e.FIRSTNAME, superior.ID as sup_id, superior.FIRSTNAME as sup_name
         * from EMPLOYEE e join EMPLOYEE superior on e.SUPERIOR_ID = superior.ID)
         * union
         * (select e.ID, e.FIRSTNAME, null, null from EMPLOYEE e)
         * order by ID asc
         */
    QEmployee superior = new QEmployee("superior");
    SubQueryExpression<Tuple> sq1 = query().from(employee).join(employee.superiorIdKey, superior).select(employee.id, employee.firstname, superior.id.as("sup_id"), superior.firstname.as("sup_name"));
    SubQueryExpression<Tuple> sq2 = query().from(employee).select(employee.id, employee.firstname, null, null);
    List<Tuple> results = query().union(sq1, sq2).orderBy(employee.id.asc()).fetch();
    for (Tuple result : results) {
        System.err.println(Arrays.asList(result));
    }
}
Also used : QEmployee(com.querydsl.sql.domain.QEmployee) Tuple(com.querydsl.core.Tuple) Ignore(org.junit.Ignore) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 33 with ExcludeIn

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

the class InsertBase method insert_dates.

@Test
// https://bitbucket.org/xerial/sqlite-jdbc/issue/133/prepstmtsetdate-int-date-calendar-seems
@ExcludeIn(SQLITE)
public void insert_dates() {
    QDateTest dateTest = QDateTest.qDateTest;
    LocalDate localDate = new LocalDate(1978, 1, 2);
    Path<LocalDate> localDateProperty = ExpressionUtils.path(LocalDate.class, "DATE_TEST");
    Path<DateTime> dateTimeProperty = ExpressionUtils.path(DateTime.class, "DATE_TEST");
    SQLInsertClause insert = insert(dateTest);
    insert.set(localDateProperty, localDate);
    insert.execute();
    Tuple result = query().from(dateTest).select(dateTest.dateTest.year(), dateTest.dateTest.month(), dateTest.dateTest.dayOfMonth(), dateTimeProperty).fetchFirst();
    assertEquals(Integer.valueOf(1978), result.get(0, Integer.class));
    assertEquals(Integer.valueOf(1), result.get(1, Integer.class));
    assertEquals(Integer.valueOf(2), result.get(2, Integer.class));
    DateTime dateTime = result.get(dateTimeProperty);
    if (target == CUBRID) {
        // XXX Cubrid adds random milliseconds for some reason
        dateTime = dateTime.withMillisOfSecond(0);
    }
    assertEquals(localDate.toDateTimeAtStartOfDay(), dateTime);
}
Also used : SQLInsertClause(com.querydsl.sql.dml.SQLInsertClause) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Tuple(com.querydsl.core.Tuple) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 34 with ExcludeIn

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

the class MergeBase method merge_with_keys_listener.

@Test
@ExcludeIn({ H2, CUBRID, SQLSERVER })
public void merge_with_keys_listener() throws SQLException {
    final AtomicBoolean result = new AtomicBoolean();
    SQLListener listener = new SQLBaseListener() {

        @Override
        public void end(SQLListenerContext context) {
            result.set(true);
        }
    };
    SQLMergeClause clause = merge(survey).keys(survey.id).set(survey.id, 7).set(survey.name, "Hello World");
    clause.addListener(listener);
    ResultSet rs = clause.executeWithKeys();
    assertTrue(rs.next());
    assertTrue(rs.getObject(1) != null);
    rs.close();
    assertTrue(result.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SQLMergeClause(com.querydsl.sql.dml.SQLMergeClause) ResultSet(java.sql.ResultSet) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 35 with ExcludeIn

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

the class SelectBase method date_add.

@Test
@ExcludeIn({ SQLITE })
public void date_add() {
    SQLQuery<?> query = query().from(employee);
    Date date1 = query.select(employee.datefield).fetchFirst();
    Date date2 = query.select(SQLExpressions.addYears(employee.datefield, 1)).fetchFirst();
    Date date3 = query.select(SQLExpressions.addMonths(employee.datefield, 1)).fetchFirst();
    Date date4 = query.select(SQLExpressions.addDays(employee.datefield, 1)).fetchFirst();
    assertTrue(date2.getTime() > date1.getTime());
    assertTrue(date3.getTime() > date1.getTime());
    assertTrue(date4.getTime() > date1.getTime());
}
Also used : Date(java.sql.Date) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Aggregations

ExcludeIn (com.querydsl.core.testutil.ExcludeIn)40 Test (org.junit.Test)38 Tuple (com.querydsl.core.Tuple)9 SQLInsertClause (com.querydsl.sql.dml.SQLInsertClause)6 ResultSet (java.sql.ResultSet)6 SAnimal (com.querydsl.jpa.domain.sql.SAnimal)4 QEmployee (com.querydsl.sql.domain.QEmployee)4 BigDecimal (java.math.BigDecimal)4 Date (java.sql.Date)4 Ignore (org.junit.Ignore)4 AbstractBaseTest (com.querydsl.sql.AbstractBaseTest)3 Group (com.querydsl.core.group.Group)2 IncludeIn (com.querydsl.core.testutil.IncludeIn)2 QCat (com.querydsl.jpa.domain.QCat)2 BigInteger (java.math.BigInteger)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ImmutableList (com.google.common.collect.ImmutableList)1 MockTuple (com.querydsl.core.group.MockTuple)1 StringPath (com.querydsl.core.types.dsl.StringPath)1 QBookMark (com.querydsl.jpa.domain4.QBookMark)1