improved SchemaStatVisitor, support function condition

This commit is contained in:
高铁
2016-01-31 23:36:45 +08:00
parent 43e9209960
commit cdeec1f73c
9 changed files with 70 additions and 5 deletions
@@ -50,7 +50,7 @@ public class MySqlUpdateTest_3 extends MysqlTest {
Assert.assertEquals(1, visitor.getTables().size());
Assert.assertEquals(5, visitor.getColumns().size());
Assert.assertEquals(1, visitor.getConditions().size());
Assert.assertEquals(3, visitor.getConditions().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("scheme.table")));
@@ -67,7 +67,7 @@ public class OracleBlockTest5 extends OracleTest {
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("ipay_contract")));
Assert.assertEquals(7, visitor.getColumns().size());
Assert.assertEquals(2, visitor.getConditions().size());
Assert.assertEquals(3, visitor.getConditions().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("departments", "department_id")));
}
@@ -11,6 +11,6 @@ public class ExportConditionsTest extends TestCase {
public void test_export_conditions() throws Exception {
String result = udf.evaluate("select * from t where id = 3 and name = 'chensheng'");
Assert.assertEquals("[[\"t.id\",\"=\",3],[\"t.name\",\"=\",\"chensheng\"]]", result);
Assert.assertEquals("[[\"t\",\"id\",\"=\",3],[\"t\",\"name\",\"=\",\"chensheng\"]]", result);
}
}
@@ -0,0 +1,16 @@
package com.alibaba.druid.bvt.support.odps.udf;
import org.junit.Assert;
import com.alibaba.druid.support.opds.udf.ExportConditions;
import junit.framework.TestCase;
public class ExportConditionsTest2 extends TestCase {
ExportConditions udf = new ExportConditions();
public void test_export_conditions() throws Exception {
String result = udf.evaluate("select * from t where proof_account is not null");
Assert.assertEquals("[[\"t\",\"proof_account\",\"IS NOT\",null]]", result);
}
}
@@ -0,0 +1,16 @@
package com.alibaba.druid.bvt.support.odps.udf;
import org.junit.Assert;
import com.alibaba.druid.support.opds.udf.ExportConditions;
import junit.framework.TestCase;
public class ExportConditionsTest3 extends TestCase {
ExportConditions udf = new ExportConditions();
public void test_export_conditions() throws Exception {
String result = udf.evaluate("select * from t where trim(name) = 'abc'");
Assert.assertEquals("[[\"t\",\"name\",\"=\",\"abc\"]]", result);
}
}
@@ -0,0 +1,16 @@
package com.alibaba.druid.bvt.support.odps.udf;
import org.junit.Assert;
import com.alibaba.druid.support.opds.udf.ExportConditions;
import junit.framework.TestCase;
public class ExportConditionsTest4 extends TestCase {
ExportConditions udf = new ExportConditions();
public void test_export_conditions() throws Exception {
String result = udf.evaluate("select * from t where trim(name) <> 'abc'");
Assert.assertEquals("[[\"t\",\"name\",\"<>\",\"abc\"]]", result);
}
}