Fixed multiple extraction eating first result

This commit is contained in:
Aleksei 2020-02-27 16:10:14 -05:00
parent c7ed16a6c8
commit eed3bb9cd5

View File

@ -262,16 +262,18 @@ public class OutfitController {
private static Optional<Collection<Outfit>> extractMultiple(ResultSet rs) throws SQLException { private static Optional<Collection<Outfit>> extractMultiple(ResultSet rs) throws SQLException {
Collection<Outfit> outfits = new ArrayList<>(); Collection<Outfit> outfits = new ArrayList<>();
if (rs.next()) { // I don't see a better way to wrap this. If results exist -> iterate through them, return the optional.
while (rs.next()) { while (rs.next()) {
outfits.add(mapObject(rs)); outfits.add(mapObject(rs));
}
FSDB.get().close(rs);
return Optional.of(outfits);
} }
FSDB.get().close(rs); FSDB.get().close(rs);
return Optional.empty();
if (outfits.size() == 0) {
return Optional.empty();
}
return Optional.of(outfits);
} }
private static Outfit mapObject(ResultSet rs) throws SQLException { private static Outfit mapObject(ResultSet rs) throws SQLException {