基于serf的数据库同步模块库
liuxiaolong
2019-09-04 2289ce31d78751b24df5a1ace2abad44355071a6
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