use of org.sagacity.sqltoy.config.model.SqlToyResult in project sagacity-sqltoy by chenrenfei.
the class SqlConfigParseUtilsTest method testProcessSql.
@Test
public void testProcessSql() {
String sql = FileUtil.readFileAsStr("classpath:scripts/ifScriptSql.sql", "UTF-8");
SqlToyResult result = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { null, "chen", "1" });
System.err.println("id==null:" + JSON.toJSONString(result));
SqlToyResult result1 = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { "1", "chen", "1" });
System.err.println("id<>null:" + JSON.toJSONString(result1));
}
use of org.sagacity.sqltoy.config.model.SqlToyResult in project sagacity-sqltoy by chenrenfei.
the class SqlConfigParseUtilsTest method testNull.
@Test
public void testNull() throws Exception {
String sql = "select * from table where 1=1 #[and id=:id and name like :name] #[and status=:status]";
SqlToyResult result = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { "1", null, "1" });
System.err.println(JSON.toJSONString(result));
}
use of org.sagacity.sqltoy.config.model.SqlToyResult in project sagacity-sqltoy by chenrenfei.
the class SqlConfigParseUtilsTest method testOptSign.
@Test
public void testOptSign() throws Exception {
String sql = "select * from table where #[id=id+:id ]#[and name like :name] #[and status=:status]";
SqlToyResult result = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { "1", null, "1" });
System.err.println(JSON.toJSONString(result));
}
use of org.sagacity.sqltoy.config.model.SqlToyResult in project sagacity-sqltoy by chenrenfei.
the class SqlConfigParseUtilsTest method testLoop.
@Test
public void testLoop() throws Exception {
String sql = "select * from table where #[id=:id and name like :name] #[and @loop(:status,' status=':status[i]'','or')]";
SqlToyResult result = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { "1", null, new Object[] { "1", "2", "3" } });
System.err.println(JSON.toJSONString(result));
result = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { "1", null, null });
System.err.println(JSON.toJSONString(result));
}
use of org.sagacity.sqltoy.config.model.SqlToyResult in project sagacity-sqltoy by chenrenfei.
the class SqlConfigParseUtilsTest method testAllNull.
@Test
public void testAllNull() throws Exception {
String sql = "select * from table where #[id=:id and name like :name] #[and status=:status]";
SqlToyResult result = SqlConfigParseUtils.processSql(sql, new String[] { "id", "name", "status" }, new Object[] { null, null, null });
System.err.println(JSON.toJSONString(result));
}
Aggregations