From 2047ae9b11d66b33010c76bc2bd1db5a5458b921 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期三, 04 九月 2019 19:44:21 +0800
Subject: [PATCH] Merge branch 'master' of ssh://192.168.1.14:29418/syncdb
---
dbself.go | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/dbself.go b/dbself.go
index 269660a..9755dfa 100644
--- a/dbself.go
+++ b/dbself.go
@@ -164,10 +164,23 @@
for _,col :=range tDescArr {
columnNames = append(columnNames, fmt.Sprintf(`'||quote("%s")||'`, col.Name))
}
- tSql = fmt.Sprintf(`SELECT 'INSERT INTO "%s" VALUES(%s)' as sql FROM "%s";`,
- table,
- strings.Join(columnNames, ","),
- table)
+ if table == "dbTables" {
+ tSql = fmt.Sprintf(`SELECT 'INSERT INTO "%s" VALUES(%s)' as sql FROM "%s" where (analyServerId='' or analyServerId is NULL);`,
+ table,
+ strings.Join(columnNames, ","),
+ table)
+ } else if table == "dbtablepersons" {
+ tSql = fmt.Sprintf(`SELECT 'INSERT INTO "%s" VALUES(%s)' as sql FROM "%s" where tableId in (select id from dbTables where (analyServerId='' or analyServerId is NULL));`,
+ table,
+ strings.Join(columnNames, ","),
+ table)
+ } else {
+ tSql = fmt.Sprintf(`SELECT 'INSERT INTO "%s" VALUES(%s)' as sql FROM "%s";`,
+ table,
+ strings.Join(columnNames, ","),
+ table)
+ }
+
fmt.Println("tSql:",tSql)
err = localDb.Raw(tSql).Scan(&dumpSql).Error
--
Gitblit v1.8.0