mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add dbtype AlibabaOracle
This commit is contained in:
@@ -21,26 +21,30 @@ import junit.framework.TestCase;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
|
||||
public class DistinctTest extends TestCase {
|
||||
|
||||
private String sql = "select count(distinct *) from t";
|
||||
|
||||
|
||||
public void test_mysql() throws Exception {
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.MYSQL));
|
||||
}
|
||||
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
|
||||
public void test_oracle_unique() throws Exception {
|
||||
Assert.assertEquals("SELECT COUNT(UNIQUE *)\nFROM t", SQLUtils.format("select count(unique *) from t", JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT COUNT(UNIQUE *)\nFROM t",
|
||||
SQLUtils.format("select count(unique *) from t", JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT COUNT(UNIQUE *)\nFROM t",
|
||||
SQLUtils.format("select count(unique *) from t", JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
|
||||
public void test_postgres() throws Exception {
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.POSTGRESQL));
|
||||
}
|
||||
|
||||
|
||||
public void test_sql92() throws Exception {
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT *)\nFROM t", SQLUtils.format(sql, null));
|
||||
}
|
||||
|
||||
@@ -21,22 +21,23 @@ import junit.framework.TestCase;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
|
||||
public class MybatisTest extends TestCase {
|
||||
|
||||
private String sql = "select * from t where id = #{id}";
|
||||
|
||||
|
||||
public void test_mysql() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.MYSQL));
|
||||
}
|
||||
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
|
||||
public void test_postgres() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.POSTGRESQL));
|
||||
}
|
||||
|
||||
|
||||
public void test_sql92() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, null));
|
||||
}
|
||||
|
||||
@@ -21,22 +21,23 @@ import junit.framework.TestCase;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
|
||||
public class MybatisTest2 extends TestCase {
|
||||
|
||||
private String sql = "select * from t where id = ${id}";
|
||||
|
||||
|
||||
public void test_mysql() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.MYSQL));
|
||||
}
|
||||
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
|
||||
public void test_postgres() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.POSTGRESQL));
|
||||
}
|
||||
|
||||
|
||||
public void test_sql92() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, null));
|
||||
}
|
||||
|
||||
@@ -32,11 +32,12 @@ public class MergeTest extends TestCase {
|
||||
String sql = "{ call INTERFACE_DATA_EXTRACTION.INVOICE_INFO(?,?,?)}";
|
||||
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.ORACLE);
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.ALI_ORACLE);
|
||||
}
|
||||
|
||||
|
||||
public void test_mergeCall_mysql() throws Exception {
|
||||
String sql = "{ call INTERFACE_DATA_EXTRACTION.INVOICE_INFO(?,?,?)}";
|
||||
|
||||
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.MYSQL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,7 @@ public class OracleFormatTest2 extends TestCase {
|
||||
|
||||
String formatedText = SQLUtils.format(text, JdbcUtils.ORACLE);
|
||||
System.out.println(formatedText);
|
||||
String formatedText2 = SQLUtils.format(text, JdbcUtils.ALI_ORACLE);
|
||||
System.out.println(formatedText2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user