use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class FreeSelectSqlBuilderTest method testSetTemplate.
@Test
public void testSetTemplate() throws SQLException {
FreeSelectSqlBuilder test = createTest();
test.setTemplate(template).setTemplate(template);
assertEquals(template + " " + template, test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class FreeSelectSqlBuilderTest method testBuildMeltdownAtBegining.
@Test
public void testBuildMeltdownAtBegining() throws SQLException {
FreeSelectSqlBuilder test = createTest();
test = createTest();
test.where(template).ignoreNull(null).and().appendExpression(template).or().appendExpression(template).ignoreNull(null).groupBy(template);
assertEquals("WHERE template GROUP BY [template]", test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class FreeSelectSqlBuilderTest method testCreate.
@Test
public void testCreate() throws SQLException {
try {
FreeSelectSqlBuilder test = new FreeSelectSqlBuilder(DatabaseCategory.MySql);
test = new FreeSelectSqlBuilder(DatabaseCategory.SqlServer);
} catch (Exception e) {
fail();
}
try {
FreeSelectSqlBuilder test = new FreeSelectSqlBuilder(DatabaseCategory.MySql);
test.setLogicDbName(logicDbName);
test.setDbCategory(DatabaseCategory.MySql);
fail();
} catch (Exception e) {
}
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class FreeSelectSqlBuilderTest method testBuildSelect.
@Test
public void testBuildSelect() throws SQLException {
FreeSelectSqlBuilder test = createTest();
test.select(template, template, template).from(tableName).where(text(template)).groupBy(template);
test.top(10).setHints(new DalHints().inTableShard(1));
assertEquals("SELECT [template], [template], [template] FROM [dal_client_test_1] WITH (NOLOCK) WHERE template GROUP BY [template] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY", test.build());
}
use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.
the class FreeSelectSqlBuilderTest method testBuildMySqlTop.
@Test
public void testBuildMySqlTop() throws SQLException {
FreeSelectSqlBuilder test = new FreeSelectSqlBuilder(DatabaseCategory.MySql);
test.setTemplate(template).setTemplate(template).append(template);
assertEquals("template template template", test.build());
test.top(10);
assertEquals("template template template limit 0, 10", test.build());
}
Aggregations