use of org.apache.ibatis.scripting.xmltags.WhereSqlNode in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREORWithTABForFirstCondition.
@Test
public void shouldTrimWHEREORWithTABForFirstCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE \t ID = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" or\t ID = ? ")), "true"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
use of org.apache.ibatis.scripting.xmltags.WhereSqlNode in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREInsteadOfANDForFirstCondition.
@Test
public void shouldTrimWHEREInsteadOfANDForFirstCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE ID = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" and ID = ? ")), "true"), new IfSqlNode(mixedContents(new TextSqlNode(" or NAME = ? ")), "false"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
use of org.apache.ibatis.scripting.xmltags.WhereSqlNode in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREANDWithCRLFForFirstCondition.
@Test
public void shouldTrimWHEREANDWithCRLFForFirstCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE \r\n ID = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" and\r\n ID = ? ")), "true"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
use of org.apache.ibatis.scripting.xmltags.WhereSqlNode in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREORWithCRLFForFirstCondition.
@Test
public void shouldTrimWHEREORWithCRLFForFirstCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE \r\n ID = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" or\r\n ID = ? ")), "true"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
use of org.apache.ibatis.scripting.xmltags.WhereSqlNode in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREInsteadOfORForSecondCondition.
@Test
public void shouldTrimWHEREInsteadOfORForSecondCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE NAME = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" and ID = ? ")), "false"), new IfSqlNode(mixedContents(new TextSqlNode(" or NAME = ? ")), "true"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
Aggregations