Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix: 修复GORM批量插入时零值字段被忽略的问题,确保IsEnabled和Flags字段正确插入

wizardchenaa81662872af
diff --git a/internal/application/repository/chunk.go b/internal/application/repository/chunk.go
index 10c5c9c7f..78433e46c 100644
--- a/internal/application/repository/chunk.go
+++ b/internal/application/repository/chunk.go
@@ -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