fix: 修复GORM批量插入时零值字段被忽略的问题,确保IsEnabled和Flags字段正确插入
parent
b2eec004c9
commit
aa81662872
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue