-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor sql parser & support tableMapping. issue #1432
- Loading branch information
Showing
7 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/com/alibaba/druid/bvt/sql/MappingTest_drop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.alibaba.druid.bvt.sql; | ||
|
||
import com.alibaba.druid.sql.SQLUtils; | ||
import com.alibaba.druid.util.JdbcConstants; | ||
import junit.framework.TestCase; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by wenshao on 16/9/25. | ||
*/ | ||
public class MappingTest_drop extends TestCase { | ||
private String sql = "drop table user"; | ||
Map<String, String> mapping = Collections.singletonMap("user", "user_01"); | ||
|
||
public void test_mapping() throws Exception { | ||
String result = SQLUtils.refactor(sql, null, mapping); | ||
assertEquals("DROP TABLE user_01", result); | ||
} | ||
|
||
public void test_mapping_mysql() throws Exception { | ||
String result = SQLUtils.refactor(sql, JdbcConstants.MYSQL, mapping); | ||
assertEquals("DROP TABLE user_01", result); | ||
} | ||
|
||
public void test_mapping_pg() throws Exception { | ||
String result = SQLUtils.refactor(sql, JdbcConstants.POSTGRESQL, mapping); | ||
assertEquals("DROP TABLE user_01", result); | ||
} | ||
|
||
public void test_mapping_oracle() throws Exception { | ||
String result = SQLUtils.refactor(sql, JdbcConstants.ORACLE, mapping); | ||
assertEquals("DROP TABLE user_01", result); | ||
} | ||
|
||
public void test_mapping_sqlserver() throws Exception { | ||
String result = SQLUtils.refactor(sql, JdbcConstants.SQL_SERVER, mapping); | ||
assertEquals("DROP TABLE user_01", result); | ||
} | ||
|
||
public void test_mapping_db2() throws Exception { | ||
String result = SQLUtils.refactor(sql, JdbcConstants.DB2, mapping); | ||
assertEquals("DROP TABLE user_01", result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters