Examples of Sql


Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

    String expected = "select USER_ID,USERNAME,PASSWORD,BIRTH_DATE,SEX,AGE from user_info where user_id = #userId# and username = :username";
    assertStringEquals(expected,sql.getIbatisSql());
  }

  public void test_select_willcard_multi_table() throws SQLException, Exception {
    Sql sql = parser.parseSql("select t1.*,t2.* from user_info t1 inner join role t2 on t1.username=t2.role_name where t1.user_id = ? and t2.role_name = :role_name");
    verifyParameters(sql,"userId","role_name");
    String expected = "select t1.USER_ID,t1.USERNAME,t1.PASSWORD,t1.BIRTH_DATE,t1.SEX,t1.AGE,t2.USER_ID,t2.USERNAME,t2.PASSWORD,t2.BIRTH_DATE,t2.SEX,t2.AGE from user_info where user_id = #userId# and username = :username";
//    assertStringEquals(expected,sql.getSql());
    //FIXME select t1.* t2.* 应该返回不同的表前缀
  }
 
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

//    assertStringEquals(expected,sql.getSql());
    //FIXME select t1.* t2.* 应该返回不同的表前缀
  }
 
  public void test_escaped() throws SQLException, Exception {
    Sql sql = parser.parseSql("select * from user_info where user_id > ? and username < :username");
    verifyParameters(sql,"userId","username");
    assertStringEquals("select USER_ID,USERNAME,PASSWORD,BIRTH_DATE,SEX,AGE from user_info where user_id > #userId# and username < :username",sql.getIbatisSql());
    assertStringEquals("select USER_ID,USERNAME,PASSWORD,BIRTH_DATE,SEX,AGE from user_info where user_id > #{userId} and username < :username",sql.getMybatisSql());
  }
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

    assertStringEquals("select USER_ID,USERNAME,PASSWORD,BIRTH_DATE,SEX,AGE from user_info where user_id > #userId# and username < :username",sql.getIbatisSql());
    assertStringEquals("select USER_ID,USERNAME,PASSWORD,BIRTH_DATE,SEX,AGE from user_info where user_id > #{userId} and username < :username",sql.getMybatisSql());
  }

  public void test_sql_function() throws SQLException, Exception {
    Sql sql = parser.parseSql("select * from user_info where username = lower(#userId#) and username != :username");
    verifyParameters(sql,"userId","username");
   
    sql = parser.parseSql("select * from user_info where username = lower(?) and username != :username");
    verifyNoParameters(sql,"userId");
    verifyParameters(sql,"username");
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

    verifyNoParameters(sql,"userId");
    verifyParameters(sql,"username");
  }
 
  public void test_insert() throws SQLException, Exception {
    Sql sql = parser.parseSql("insert into user_info(user_id,username,password) values (?,?,?)");
    verifyParameters(sql,"userId","username","password");
  }
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

    verifyParameters(sql,"userId","username","password");
  }
 
  public void test_insert_with_userId_not_null() throws SQLException, Exception {
    try {
    Sql sql = parser.parseSql("insert into user_info(username,password) values (?,?)");
    fail("user_id must be not null");
    }catch(Exception e) {
      assertTrue(true);
    }
  }
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

      assertTrue(true);
    }
  }
 
  public void test_delete() throws SQLException, Exception {
    Sql sql = parser.parseSql("delete from user_info where username = ? and password = ? and age = ? or (sex >= ?)");
    verifyParameters(sql,"username","password","age","sex");
    assertEquals("delete from user_info where username = #username# and password = #password# and age = #age# or (sex >= #sex#)",sql.getIbatisSql());
    assertEquals("delete from user_info where username = #{username} and password = #{password} and age = #{age} or (sex >= #{sex})",sql.getMybatisSql());
    assertEquals("delete from user_info where username = :username and password = :password and age = :age or (sex >= :sex)",sql.getSpringJdbcSql());
    assertEquals("delete from user_info where username = :username and password = :password and age = :age or (sex >= :sex)",sql.getHql());
  }
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

    assertEquals("delete from user_info where username = #{username} and password = #{password} and age = #{age} or (sex >= #{sex})",sql.getMybatisSql());
    assertEquals("delete from user_info where username = :username and password = :password and age = :age or (sex >= :sex)",sql.getSpringJdbcSql());
    assertEquals("delete from user_info where username = :username and password = :password and age = :age or (sex >= :sex)",sql.getHql());
  }
  public void test_update() throws SQLException, Exception {
    Sql sql = parser.parseSql("update user_info set username = ? , password = ? , age = ? , sex = ?");
    verifyParameters(sql,"username","password","age","sex");
    assertEquals("update user_info set username = #username# , password = #password# , age = #age# , sex = #sex#",sql.getIbatisSql());
  }
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

    assertEquals("update user_info set username = #username# , password = #password# , age = #age# , sex = #sex#",sql.getIbatisSql());
  }

   public void test_select_as_alias_h2() {
       
        Sql sql = parser.parseSql("SELECT username user,password pwd from user_info");
        System.out.println("columns:"+sql.getColumns());
        verifyColumns(sql, "user","pwd");
    }
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

        assertEquals(segment.getParamNames().get(0),"username");
        assertEquals(segment.getParamNames().get(1),"password");
        assertEquals(segment.getParamNames().get(2),"age");
        assertEquals(segment.getClassName(),"UserInfoWhere");
       
        Sql sql = new SqlFactory().parseSql(parser.resultSql);
        assertEquals(get(segment.getParams(sql),0).getParamName(),"username");
        assertEquals(get(segment.getParams(sql),1).getParamName(),"password");
        assertEquals(get(segment.getParams(sql),2).getParamName(),"age");
       
        assertEquals(get(segment.getParams(sql),0).getParameterClass(),"String");
View Full Code Here

Examples of cn.org.rapid_framework.generator.provider.db.sql.model.Sql

        assertEquals(segment.getParamNames().get(0),"username");
        assertEquals(segment.getParamNames().get(1),"password");
//        assertEquals(segment.getParamNames().get(2),"age"); // TODO 现在不支持 age = ?
        assertEquals(segment.getClassName(),"UserInfoWhere");
       
        Sql sql = new SqlFactory().parseSql(parser.resultSql);
        assertEquals(get(segment.getParams(sql),0).getParamName(),"username");
        assertEquals(get(segment.getParams(sql),1).getParamName(),"password");
//        assertEquals(get(segment.getParams(sql),2).getParamName(),"age");
       
        assertEquals(get(segment.getParams(sql),0).getParameterClass(),"String");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.