Package org.nutz.dao.sql

Examples of org.nutz.dao.sql.Sql


  }

  @Test
  public void check_Create_SQL() {
    SqlManager sqls = createSqls();
    Sql sql = sqls.create(".abc.create");
    assertTrue(sql.toString().toUpperCase().startsWith("CREATE"));
  }
View Full Code Here


  }

  @Test
  public void check_Insert_SQL() {
    SqlManager sqls = createSqls();
    Sql sql = sqls.create(".abc.insert");
    assertTrue(sql.toString().toUpperCase().startsWith("INSERT"));
  }
View Full Code Here

  }

  @Test
  public void check_Update_SQL() {
    SqlManager sqls = createSqls();
    Sql sql = sqls.create(".abc.update");
    assertTrue(sql.toString().toUpperCase().startsWith("UPDATE"));
  }
View Full Code Here

  }

  @Test
  public void check_Fetch_SQL() {
    SqlManager sqls = createSqls();
    Sql sql = sqls.create("abc.fetch");
    assertTrue(sql.toString().toUpperCase().startsWith("SELECT"));
  }
View Full Code Here

  }

  @Test
  public void check_Query_SQL() {
    SqlManager sqls = createSqls();
    Sql sql = sqls.create("abc.query");
    assertTrue(sql.toString().toUpperCase().startsWith("SELECT"));
  }
View Full Code Here

  @Test
  public void test_parse_whole_directory() {
    SqlManager sqls = new FileSqlManager("org/nutz/dao/test/sqls/dir");
    assertTrue(sqls.count() > 0);
    Sql sql = sqls.create(".abc.update");
    sql.params().set("name", "ABC");
    sql.params().set("id", 16);
    assertEquals("UPDATE t_abc SET name='ABC' WHERE id=16;", sql.toString());
  }
View Full Code Here

public class SqlImplTest {

  @Test
  public void test_sql_get_list() {
    Sql sql = Sqls.create("SELECT version()");
    ArrayList<Map<Object, Object>> list = new ArrayList<Map<Object, Object>>();
    list.add(new HashMap<Object, Object>());
    list.add(new HashMap<Object, Object>());

    sql.getContext().setResult(list);

    List<?> re = sql.getList(Map.class);// 传入 map结果会导致上面的isFrom 为false
    assertTrue(re == list);

    re = sql.getList(HashMap.class);// 因为list中的实例是HashMap,因此能够正常返回
    assertTrue(re == list);
  }
View Full Code Here

public class CustomizedSqlsTest extends DaoCase {

  @Test
  public void test_escape_varname_test() {
    Sql sql = Sqls.create("A_$xyz$_B");
    sql.vars().set("xyz", "X");
    assertEquals("A_X_B", sql.toString());
  }
View Full Code Here

  }

  @Test
  public void clear_links() {
    dao.create(Pet.class, true);
    Sql sql1 = Sqls.create("INSERT INTO t_pet (name) VALUES ('A')");
    Sql sql2 = Sqls.create("INSERT INTO t_pet (nocol) VALUES ('B')");
    try {
      dao.execute(sql1, sql2);
      fail();
    }
    catch (DaoException e) {}
View Full Code Here

  }

  @Test
  public void run_2_sqls_with_error() {
    assertEquals(0, dao.count(Pet.class));
    Sql sql1 = Sqls.create("INSERT INTO t_pet (name) VALUES ('A')");
    Sql sql2 = Sqls.create("INSERT INTO t_pet (nocol) VALUES ('B')");
    try {
      dao.execute(sql1, sql2);
      fail();
    }
    catch (DaoException e) {}
View Full Code Here

TOP

Related Classes of org.nutz.dao.sql.Sql

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.