Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: use create table like to be compatible with tidb (#9879)
Danny Xu66f0ddce4320
diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.goindex 40e6a33785..b26d002a63 100644--- a/backend/runner/taskrun/data_update_executor.go+++ b/backend/runner/taskrun/data_update_executor.go@@ -138,5 +138,5 @@ func updateToSelect(statement, databaseName, suffix string) string {setIndex := strings.Index(lowerStatement, "set")tableName := strings.Trim(statement[updateIndex+6:setIndex], " \n\t")targetTableName := fmt.Sprintf("%s.%s%s", databaseName, tableName, suffix)- return fmt.Sprintf("CREATE TABLE %s AS SELECT * FROM %s %s", targetTableName, tableName, condition)+ return fmt.Sprintf("CREATE TABLE %s LIKE %s; INSERT INTO %s SELECT * FROM %s %s", targetTableName, tableName, targetTableName, tableName, condition)}diff --git a/backend/runner/taskrun/data_update_executor_test.go b/backend/runner/taskrun/data_update_executor_test.goindex 882eeaa188..274022e430 100644--- a/backend/runner/taskrun/data_update_executor_test.go+++ b/backend/runner/taskrun/data_update_executor_test.go@@ -8,5 +8,5 @@ import (func TestUpdateToSelect(t *testing.T) {got := updateToSelect("UPDATE hello SET column1 = value1, column2 = value2 WHERE id > 3;", "todozp", "113")- assert.Equal(t, "CREATE TABLE todozp.hello113 AS SELECT * FROM hello WHERE id > 3;", got)+ assert.Equal(t, "CREATE TABLE todozp.hello113 LIKE hello; INSERT INTO todozp.hello113 SELECT * FROM hello WHERE id > 3;", got)}