fix: 修复GORM批量插入时零值字段被忽略的问题,确保IsEnabled和Flags字段正确插入
This commit is contained in:
@@ -27,7 +27,9 @@ func (r *chunkRepository) CreateChunks(ctx context.Context, chunks []*types.Chun
|
||||
for _, chunk := range chunks {
|
||||
chunk.Content = common.CleanInvalidUTF8(chunk.Content)
|
||||
}
|
||||
return r.db.WithContext(ctx).CreateInBatches(chunks, 100).Error
|
||||
// Use Select("*") to ensure all fields including zero values (IsEnabled=false, Flags=0)
|
||||
// are inserted, bypassing GORM's default value behavior for zero values
|
||||
return r.db.WithContext(ctx).Select("*").CreateInBatches(chunks, 100).Error
|
||||
}
|
||||
|
||||
// GetChunkByID retrieves a chunk by its ID and tenant ID
|
||||
|
||||
Reference in New Issue
Block a user