diff --git a/src/main/java/telraam/database/daos/TeamDAO.java b/src/main/java/telraam/database/daos/TeamDAO.java index e983c57..77d8c84 100644 --- a/src/main/java/telraam/database/daos/TeamDAO.java +++ b/src/main/java/telraam/database/daos/TeamDAO.java @@ -19,7 +19,7 @@ public interface TeamDAO extends DAO { List getAll(); @Override - @SqlUpdate("INSERT INTO team (name, baton_id) VALUES (:name, :batonId)") + @SqlUpdate("INSERT INTO team (name, baton_id, jacket_nr) VALUES (:name, :batonId, :jacketNr)") @GetGeneratedKeys({"id"}) int insert(@BindBean Team team); @@ -33,9 +33,6 @@ public interface TeamDAO extends DAO { int deleteById(@Bind("id") int id); @Override - @SqlUpdate("UPDATE team SET " + - "name = :name," + - "baton_id = :batonId " + - "WHERE id = :id") + @SqlUpdate("UPDATE team SET name = :name, baton_id = :batonId, jacket_nr = :jacketNr WHERE id = :id") int update(@Bind("id") int id, @BindBean Team modelObj); } diff --git a/src/main/java/telraam/database/models/Team.java b/src/main/java/telraam/database/models/Team.java index 94db208..eb5e086 100644 --- a/src/main/java/telraam/database/models/Team.java +++ b/src/main/java/telraam/database/models/Team.java @@ -9,6 +9,7 @@ public class Team { private Integer id; private String name; private Integer batonId; + private String jacketNr = "INVALID"; public Team(String name) { this.name = name; diff --git a/src/main/resources/db/migration/V16__Add_team_jacket_nr.sql b/src/main/resources/db/migration/V16__Add_team_jacket_nr.sql new file mode 100644 index 0000000..9b261db --- /dev/null +++ b/src/main/resources/db/migration/V16__Add_team_jacket_nr.sql @@ -0,0 +1 @@ +alter table team add jacket_nr varchar(255) default 'INVALID' not null; \ No newline at end of file diff --git a/src/test/java/telraam/database/daos/TeamDAOTest.java b/src/test/java/telraam/database/daos/TeamDAOTest.java index 775efa9..7dae6b7 100644 --- a/src/test/java/telraam/database/daos/TeamDAOTest.java +++ b/src/test/java/telraam/database/daos/TeamDAOTest.java @@ -103,12 +103,14 @@ void testUpdateDoesUpdate() { int testid = teamDAO.insert(testTeam); testTeam.setId(testid); testTeam.setName("postupdate"); + testTeam.setJacketNr("10"); int updatedRows = teamDAO.update(testid, testTeam); assertEquals(1, updatedRows); Optional dbTeam = teamDAO.getById(testid); assertFalse(dbTeam.isEmpty()); assertEquals("postupdate", dbTeam.get().getName()); + assertEquals("10", dbTeam.get().getJacketNr()); } @Test