Fix PRIMARY KEY constraint handling in auction import
- Handle both auction_id and URL constraint failures - Add fallback UPDATE by URL when INSERT fails - Properly catch and log constraint violations without propagating - Fixes import errors on server with duplicate auctions
This commit is contained in:
@@ -481,6 +481,9 @@ public class DatabaseService {
|
||||
} else {
|
||||
log.debug("Updated existing auction by URL: {}", auction.url());
|
||||
}
|
||||
} catch (SQLException updateEx) {
|
||||
// UPDATE also failed - log and swallow the exception
|
||||
log.warn("Failed to update auction by URL ({}): {}", auction.url(), updateEx.getMessage());
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
@@ -844,8 +847,12 @@ public class DatabaseService {
|
||||
}
|
||||
upsertAuction(auction);
|
||||
imported.add(auction);
|
||||
} catch (SQLException e) {
|
||||
// SQLException should be handled by upsertAuction, but if it propagates here, log it
|
||||
log.warn("Failed to import auction (SQL error): {}", e.getMessage());
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to import auction: " + e.getMessage());
|
||||
// Other exceptions (parsing errors, etc)
|
||||
log.warn("Failed to import auction (parsing error): {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
Reference in New Issue
Block a user