|
|
@@ -53,7 +53,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
|
if (sql.contains("ADD")) { |
|
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
|
sql = sql.substring(sql.indexOf("ADD COLUMN")); |
|
|
|
String[] sqls = sql.split(","); |
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
|
for (String str : sqls) { |
|
|
|
String[] ss = str.split(" "); |
|
|
|
sb.append(" ADD COLUMN ").append(ss[2]).append(" ").append(convertFieldType(ss[3])).append(" NULL ").append(","); |
|
|
@@ -62,7 +62,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
|
} else if (sql.contains("DROP")) { |
|
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
|
sql = sql.substring(sql.indexOf("DROP COLUMN")); |
|
|
|
String[] sqls = sql.split(","); |
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
|
for (String str : sqls) { |
|
|
|
String[] ss = str.split(" "); |
|
|
|
sb.append(" DROP COLUMN ").append(ss[2]).append(","); |
|
|
@@ -71,7 +71,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
|
|
|
|
|
} else if (sql.contains("CHANGE")) { |
|
|
|
sql = sql.substring(sql.indexOf("CHANGE COLUMN")); |
|
|
|
String[] sqls = sql.split(","); |
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
|
for (String str : sqls) { |
|
|
|
String[] ss = str.split(" "); |
|
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()).append(" RENAME COLUMN ").append(ss[2]).append(" TO ").append(ss[3]).append(";"); |
|
|
@@ -80,7 +80,7 @@ public class KbSqlFileWork extends AbstractFileWork { |
|
|
|
} else if (sql.contains("MODIFY")) { |
|
|
|
sb.append("ALTER TABLE public.").append(canalVO.getTableName()); |
|
|
|
sql = sql.substring(sql.indexOf("MODIFY COLUMN")); |
|
|
|
String[] sqls = sql.split(","); |
|
|
|
String[] sqls = sql.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)", -1); |
|
|
|
for (String str : sqls) { |
|
|
|
String[] ss = str.split(" "); |
|
|
|
sb.append(" ALTER COLUMN ").append(ss[2]).append(" TYPE ").append(convertFieldType(ss[3])).append(","); |
|
|
|