Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: filter out column position (#13345)

h3n4lbdc951a034ca
diff --git a/backend/api/v1/branch_merge.go b/backend/api/v1/branch_merge.go
index dcf3b0d66c..48d5a6b728 100644
--- a/backend/api/v1/branch_merge.go
+++ b/backend/api/v1/branch_merge.go
@@ -560,12 +560,6 @@ func (n *metadataDiffTableNode) applyDiffTo(target *storepb.SchemaMetadata) erro
}
}
- // XXX(zp): We need to find a better way to solve the problem of column position.
- // We need to sort the columns by position after applying the diff.
- for idx := range newTable.Columns {
- newTable.Columns[idx].Position = int32(idx + 1)
- }
-
for _, foreignKeyName := range sortedForeignKeyName {
foreignKey := n.foreignKeys[foreignKeyName]
if err := foreignKey.applyDiffTo(newTable); err != nil {
@@ -629,12 +623,6 @@ func (n *metadataDiffTableNode) applyDiffTo(target *storepb.SchemaMetadata) erro
return errors.Wrapf(err, "failed to apply diff to index %q", index.name)
}
}
- // XXX(zp): We need to find a better way to solve the problem of column position.
- // We need to sort the columns by position after applying the diff.
- for idx := range newTable.Columns {
- newTable.Columns[idx].Position = int32(idx + 1)
- }
-
for _, partitionName := range n.partitionNames {
partition := n.partitionsMap[partitionName]
if err := partition.applyDiffTo(newTable); err != nil {
diff --git a/backend/api/v1/branch_merge_test.go b/backend/api/v1/branch_merge_test.go
index a34cd65085..a60000481a 100644
--- a/backend/api/v1/branch_merge_test.go
+++ b/backend/api/v1/branch_merge_test.go
@@ -33,7 +33,7 @@ func TestTryMerge(t *testing.T) {
a := require.New(t)
- testFilepath := "testdata/schema_design_merge/try_merge.yaml"
+ testFilepath := "testdata/branch_merge/try_merge.yaml"
content, err := os.ReadFile(testFilepath)
a.NoError(err)
var testCases []testCase
diff --git a/backend/api/v1/branch_service.go b/backend/api/v1/branch_service.go
index ec0075f317..4340e6ef5f 100644
--- a/backend/api/v1/branch_service.go
+++ b/backend/api/v1/branch_service.go
@@ -982,7 +982,6 @@ func filterDatabaseMetadataByEngine(metadata *storepb.DatabaseSchemaMetadata, en
Type: column.Type,
DefaultValue: column.DefaultValue,
Nullable: column.Nullable,
- Position: column.Position,
}
filteredTable.Columns = append(filteredTable.Columns, filteredColumn)
}
diff --git a/backend/api/v1/testdata/schema_design_merge/try_merge.yaml b/backend/api/v1/testdata/branch_merge/try_merge.yaml
similarity index 93%
rename from backend/api/v1/testdata/schema_design_merge/try_merge.yaml
rename to backend/api/v1/testdata/branch_merge/try_merge.yaml
index dbadb26d6b..dc45dffbb1 100644
--- a/backend/api/v1/testdata/schema_design_merge/try_merge.yaml
+++ b/backend/api/v1/testdata/branch_merge/try_merge.yaml
@@ -12,7 +12,6 @@
"name": "id",
"type": "int",
"nullable": true,
- "position": 1,
"defaultNull": true
}
],
@@ -53,7 +52,6 @@
"name": "id",
"type": "int",
"nullable": true,
- "position": 1,
"defaultNull": true
}
],
@@ -87,7 +85,6 @@
"name": "id",
"type": "int",
"nullable": true,
- "position": 1,
"defaultNull": true
}
],
@@ -124,7 +121,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"defaultNull": true,
"nullable": true,
"type": "int"
@@ -189,7 +185,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"defaultNull": true,
"nullable": true,
"type": "INT"
@@ -232,7 +227,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"defaultNull": true,
"nullable": true,
"type": "INT"
@@ -293,8 +287,7 @@
"columns": [
{
"name": "id",
- "position": 1,
- "defaultNull": true,
+ "defaultNull": true,
"nullable": true,
"type": "INT"
}
@@ -360,7 +353,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"defaultNull": true,
"nullable": true,
"type": "INT"
@@ -467,17 +459,14 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "varchar(255)"
},
{
"name": "c",
- "position": 2,
"type": "int"
}
],
@@ -514,7 +503,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -536,22 +524,18 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "c",
- "position": 2,
"type": "int"
},
{
"name": "gender",
- "position": 3,
"type": "char(1)"
},
{
"name": "credit_card_number",
- "position": 4,
"type": "varchar(255)"
}
],
@@ -580,12 +564,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "employee_id",
- "position": 2,
"type": "integer"
}
],
@@ -629,27 +611,22 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "varchar(255)"
},
{
"name": "c",
- "position": 3,
"type": "int"
},
{
"name": "gender",
- "position": 4,
"type": "char(1)"
},
{
"name": "debit_card_number",
- "position": 5,
"type": "varchar(255)"
}
],
@@ -679,7 +656,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -689,12 +665,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "employee_id",
- "position": 2,
"type": "integer"
}
]
@@ -704,17 +678,14 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "address",
- "position": 2,
"type": "varchar(255)"
},
{
"name": "employee_id",
- "position": 3,
"type": "integer"
}
],
@@ -758,27 +729,22 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "c",
- "position": 2,
"type": "int"
},
{
"name": "gender",
- "position": 3,
"type": "char(1)"
},
{
"name": "debit_card_number",
- "position": 4,
"type": "varchar(255)"
},
{
"name": "credit_card_number",
- "position": 5,
"type": "varchar(255)"
}
],
@@ -807,17 +773,14 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "address",
- "position": 2,
"type": "varchar(255)"
},
{
"name": "employee_id",
- "position": 3,
"type": "integer"
}
],
@@ -849,12 +812,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "employee_id",
- "position": 2,
"type": "integer"
}
]
@@ -877,7 +838,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -899,12 +859,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "varchar(255)"
}
]
@@ -926,12 +884,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "gender",
- "position": 2,
"type": "char(1)"
}
]
@@ -953,17 +909,14 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "gender",
- "position": 2,
"type": "char(1)"
},
{
"name": "name",
- "position": 3,
"type": "varchar(255)"
}
]
@@ -986,12 +939,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "text"
}
]
@@ -1013,12 +964,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "text"
}
]
@@ -1040,12 +989,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "text"
}
],
@@ -1076,12 +1023,10 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
},
{
"name": "name",
- "position": 2,
"type": "text"
}
],
@@ -1113,7 +1058,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1135,7 +1079,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1166,7 +1109,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1197,7 +1139,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1207,7 +1148,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1217,7 +1157,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1240,7 +1179,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1262,7 +1200,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1284,7 +1221,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1306,7 +1242,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "integer"
}
]
@@ -1329,7 +1264,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "int"
}
]
@@ -1351,7 +1285,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "int"
}
]
@@ -1373,7 +1306,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "int(11)"
}
]
@@ -1395,7 +1327,6 @@
"columns": [
{
"name": "id",
- "position": 1,
"type": "int(11)"
}
]
diff --git a/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue b/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue
index 9aa6a6d0e7..274c20aa0d 100644
--- a/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue
+++ b/frontend/src/components/Branch/BranchRebaseView/BranchRebaseView.vue
@@ -74,11 +74,7 @@ import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import MaskSpinner from "@/components/misc/MaskSpinner.vue";
import { branchServiceClient } from "@/grpcweb";
-import {
- pushNotification,
- useBranchStore,
- useDatabaseV1Store,
-} from "@/store";
+import { pushNotification, useBranchStore, useDatabaseV1Store } from "@/store";
import type { ComposedProject } from "@/types";
import { isValidDatabaseName } from "@/types";
import type { Branch } from "@/types/proto/v1/branch_service";