Merge pull request #12 from alibaba/master

merge
This commit is contained in:
rewerma
2018-10-23 15:38:45 +08:00
committed by GitHub
5 changed files with 35 additions and 7 deletions
@@ -86,7 +86,8 @@ public class MysqlGTIDSet implements GTIDSet {
if (gtidData == null || gtidData.length() < 1) {
m = new HashMap<String, UUIDSet>();
} else {
String[] uuidStrs = gtidData.split(",");
// 存在多个GTID时会有回车符
String[] uuidStrs = gtidData.replaceAll("\n", "").split(",");
m = new HashMap<String, UUIDSet>(uuidStrs.length);
for (int i = 0; i < uuidStrs.length; i++) {
UUIDSet uuidSet = UUIDSet.parse(uuidStrs[i]);
@@ -18,13 +18,17 @@ public class FastsqlSchemaTest {
@Test
public void testSimple() throws FileNotFoundException, IOException {
SchemaRepository repository = new SchemaRepository(JdbcConstants.MYSQL);
String sql = "create table yushitai_test.card_record ( id bigint auto_increment) auto_increment=256 "
+ "; alter table yushitai_test.card_record add column customization_id bigint unsigned NOT NULL COMMENT 'TEST' ;"
+ "; rename table yushitai_test.card_record to yushitai_test._card_record_del;";
String sql = "create table yushitai_test.card_record ( id bigint auto_increment, name varchar(32) DEFAULT NULL) auto_increment=256 "
+ "alter table yushitai_test.card_record add index index_name(name) ;"
+ "alter table yushitai_test.card_record add index index_name(name) ;"
+ "alter table yushitai_test.card_record add Constraint pk_id PRIMARY KEY (id);"
+ "alter table yushitai_test.card_record add Constraint pk_id PRIMARY KEY (id);"
+ "alter table yushitai_test.card_record add Constraint UNIQUE index uk_name(name);"
+ "alter table yushitai_test.card_record add Constraint UNIQUE index uk_name(name);";
repository.console(sql);
repository.setDefaultSchema("yushitai_test");
SchemaObject table = repository.findTable("_card_record_del");
SchemaObject table = repository.findTable("card_record");
System.out.println(table.getStatement().toString());
}
}
@@ -37,4 +37,19 @@ public class MemoryTableMeta_DDL_Test {
meta = memoryTableMeta.find("yushitai_test", "_card_record_gho");
Assert.assertNull(meta);
}
@Test
public void test2() throws Throwable {
MemoryTableMeta memoryTableMeta = new MemoryTableMeta();
URL url = Thread.currentThread().getContextClassLoader().getResource("dummy.txt");
File dummyFile = new File(url.getFile());
File create = new File(dummyFile.getParent() + "/ddl", "ddl_test2.sql");
String sql = StringUtils.join(IOUtils.readLines(new FileInputStream(create)), "\n");
memoryTableMeta.apply(null, "test", sql, null);
TableMeta meta = memoryTableMeta.find("yushitai_test", "card_record");
System.out.println(meta);
Assert.assertEquals(meta.getFieldMetaByName("id").isKey(), true);
Assert.assertEquals(meta.getFieldMetaByName("name").isUnique(), true);
}
}
@@ -0,0 +1,8 @@
CREATE TABLE yushitai_test.card_record (
id bigint AUTO_INCREMENT,
name varchar(32) DEFAULT NULL,
alias varchar(32) DEFAULT NULL,
INDEX index_name(name),
CONSTRAINT pk_id PRIMARY KEY (id),
UNIQUE uk_name (name,alias)
) AUTO_INCREMENT = 256
+2 -2
View File
@@ -99,7 +99,7 @@
<java_source_version>1.7</java_source_version>
<java_target_version>1.7</java_target_version>
<file_encoding>UTF-8</file_encoding>
<spring_version>3.2.9.RELEASE</spring_version>
<spring_version>3.2.18.RELEASE</spring_version>
</properties>
<modules>
@@ -247,7 +247,7 @@
<dependency>
<groupId>com.alibaba.fastsql</groupId>
<artifactId>fastsql</artifactId>
<version>2.0.0_preview_617</version>
<version>2.0.0_preview_630</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>