Skip to content

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

chore: sync index length for mysql (#10454)

h3n4ld457e29e47f0
diff --git a/backend/plugin/db/mysql/sync.go b/backend/plugin/db/mysql/sync.go
index 17f3f78c26..74f1c1b2af 100644
--- a/backend/plugin/db/mysql/sync.go
+++ b/backend/plugin/db/mysql/sync.go
@@ -143,6 +143,7 @@ func (driver *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchema
TABLE_NAME,
INDEX_NAME,
COLUMN_NAME,
+ IFNULL(SUB_PART, -1),
'',
SEQ_IN_INDEX,
INDEX_TYPE,
@@ -162,6 +163,7 @@ func (driver *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchema
TABLE_NAME,
INDEX_NAME,
COLUMN_NAME,
+ IFNULL(SUB_PART, -1),
EXPRESSION,
SEQ_IN_INDEX,
INDEX_TYPE,
@@ -182,11 +184,13 @@ func (driver *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchema
var columnName sql.NullString
var expressionName sql.NullString
var position int
+ var subPart int64
var unique, visible bool
if err := indexRows.Scan(
&tableName,
&indexName,
&columnName,
+ &subPart,
&expressionName,
&position,
&indexType,
@@ -219,6 +223,7 @@ func (driver *Driver) SyncDBSchema(ctx context.Context) (*storepb.DatabaseSchema
}
}
indexMap[key][indexName].Expressions = append(indexMap[key][indexName].Expressions, expression)
+ indexMap[key][indexName].KeyLength = append(indexMap[key][indexName].KeyLength, subPart)
}
if err := indexRows.Err(); err != nil {
return nil, util.FormatErrorWithQuery(err, indexQuery)
diff --git a/backend/tests/syncer_test.go b/backend/tests/syncer_test.go
index 4bb736e16d..c771058b59 100644
--- a/backend/tests/syncer_test.go
+++ b/backend/tests/syncer_test.go
@@ -272,6 +272,9 @@ func TestSyncerForMySQL(t *testing.T) {
"expressions":[
"id"
],
+ "keyLength": [
+ "-1"
+ ],
"type":"BTREE",
"unique":true,
"primary":true,
@@ -318,6 +321,11 @@ func TestSyncerForMySQL(t *testing.T) {
"b",
"c"
],
+ "keyLength": [
+ -1,
+ -1,
+ -1
+ ],
"type":"BTREE",
"visible":true
}
@@ -395,6 +403,11 @@ func TestSyncerForMySQL(t *testing.T) {
"b",
"c"
],
+ "keyLength": [
+ -1,
+ -1,
+ -1
+ ],
"type":"BTREE",
"unique":true,
"visible":true