功能:添加可空字段和标签格式支持
- 实现可空字段(nullable)功能 - 支持 *int, *string 等指针类型 - 添加 nullable 示例程序 - 完善可空字段验证测试 - 添加标签格式(tag format)支持 - 支持自定义字段标签 - 添加 tag_format 示例程序 - 增强 Schema 标签解析能力 - 优化 Schema 和 SSTable 处理逻辑 - 添加诊断工具测试用例
This commit is contained in:
@@ -189,8 +189,8 @@ func encodeSSTableRowBinary(row *SSTableRow, schema *Schema) ([]byte, error) {
|
||||
fieldBuf := new(bytes.Buffer)
|
||||
value, exists := row.Data[field.Name]
|
||||
|
||||
if !exists {
|
||||
// 字段不存在,写入零值
|
||||
if !exists || value == nil {
|
||||
// 字段不存在或值为 nil(nullable 字段),写入零值
|
||||
if err := writeFieldZeroValue(fieldBuf, field.Type); err != nil {
|
||||
return nil, fmt.Errorf("write zero value for field %s: %w", field.Name, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user