mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add test
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.alibaba.druid.bvt.mapping;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -38,6 +40,30 @@ public class MySqlMappingShardingTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(expected, sql);
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String oql = "select * from 用户 u where u.名称 = ?";
|
||||
|
||||
String sql = engine.explainToSelectSQL(oql, Collections.<Object>singletonList("a"));
|
||||
|
||||
String expected = "SELECT uid AS \"名称\", name AS \"昵称\"\n" + //
|
||||
"FROM user_a u\n" + //
|
||||
"WHERE u.uid = ?";
|
||||
|
||||
Assert.assertEquals(expected, sql);
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
String oql = "select * from 用户 u where u.名称 = ?";
|
||||
|
||||
String sql = engine.explainToSelectSQL(oql, Collections.<Object>singletonList("b"));
|
||||
|
||||
String expected = "SELECT uid AS \"名称\", name AS \"昵称\"\n" + //
|
||||
"FROM user_x u\n" + //
|
||||
"WHERE u.uid = ?";
|
||||
|
||||
Assert.assertEquals(expected, sql);
|
||||
}
|
||||
|
||||
public static class ShardingMappingEngine extends MappingEngine {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user