🐛 fix(query): 统一处理 []byte(nil) 为 NULL,修复表格数据显示异常

- 覆盖 mysql/postgres/kingbase/oracle/dameng/sqlite/custom 的 Query 返回值转换
  - 修正可编辑表格保存范围,避免状态残留影响显示
This commit is contained in:
杨国锋
2026-02-03 14:27:10 +08:00
parent aa7651d95c
commit 2ca27ebfb0
8 changed files with 37 additions and 8 deletions

View File

@@ -116,7 +116,7 @@ const EditableCell: React.FC<EditableCellProps> = React.memo(({
const save = async () => {
try {
if (!form) return;
const values = await form.validateFields();
const values = await form.validateFields([dataIndex]);
toggleEdit();
handleSave({ ...record, ...values });
} catch (errInfo) {
@@ -285,6 +285,7 @@ const DataGrid: React.FC<DataGridProps> = ({
setModifiedRows({});
setDeletedRowKeys(new Set());
setSelectedRowKeys([]);
form.resetFields();
}, [tableName, dbName, connectionId]); // Reset on context change
const displayData = useMemo(() => {

View File

@@ -92,7 +92,11 @@ func (c *CustomDB) Query(query string) ([]map[string]interface{}, []string, erro
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}

View File

@@ -123,7 +123,11 @@ func (d *DamengDB) Query(query string) ([]map[string]interface{}, []string, erro
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}

View File

@@ -154,7 +154,11 @@ func (k *KingbaseDB) Query(query string) ([]map[string]interface{}, []string, er
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}

View File

@@ -111,7 +111,11 @@ func (m *MySQLDB) Query(query string) ([]map[string]interface{}, []string, error
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}

View File

@@ -129,7 +129,11 @@ func (o *OracleDB) Query(query string) ([]map[string]interface{}, []string, erro
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}

View File

@@ -112,7 +112,11 @@ rows, err := p.conn.Query(query)
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}

View File

@@ -87,7 +87,11 @@ func (s *SQLiteDB) Query(query string) ([]map[string]interface{}, []string, erro
val := values[i]
b, ok := val.([]byte)
if ok {
v = string(b)
if b == nil {
v = nil
} else {
v = string(b)
}
} else {
v = val
}