fix: prevent duplicate partnumbers in stock mappings table
Add duplicate detection before batch insert of auto-mappings: - Query existing partnumbers from lot_partnumbers table - Build case-insensitive set of existing entries - Filter out duplicates before CreateInBatches - Also prevent duplicates within single batch This ensures partnumber uniqueness as primary key requires. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1007,7 +1007,7 @@ func (h *PricingHandler) ImportStockLog(c *gin.Context) {
|
||||
"deleted": result.Deleted,
|
||||
"unmapped": result.Unmapped,
|
||||
"conflicts": result.Conflicts,
|
||||
"fallback_matches": result.FallbackMatches,
|
||||
"auto_mapped": result.AutoMapped,
|
||||
"parse_errors": result.ParseErrors,
|
||||
"qty_parse_errors": result.QtyParseErrors,
|
||||
"ignored": result.Ignored,
|
||||
@@ -1042,7 +1042,7 @@ func (h *PricingHandler) ImportStockLog(c *gin.Context) {
|
||||
"deleted": p.Deleted,
|
||||
"unmapped": p.Unmapped,
|
||||
"conflicts": p.Conflicts,
|
||||
"fallback_matches": p.FallbackMatches,
|
||||
"auto_mapped": p.AutoMapped,
|
||||
"parse_errors": p.ParseErrors,
|
||||
"qty_parse_errors": p.QtyParseErrors,
|
||||
"ignored": p.Ignored,
|
||||
|
||||
Reference in New Issue
Block a user