From c637756b9cc24a187067993516df6b2813a12531 Mon Sep 17 00:00:00 2001 From: Ryan Cicchiello Date: Sun, 20 Jan 2019 19:21:29 -0500 Subject: [PATCH] Fixed bug where role_id was attemping to be set to null causing a failed contraint check --- libaris/src/main/resources/edu/rpi/aris/VERSION | 2 +- .../main/java/edu/rpi/aris/assign/message/ClassCreateMsg.java | 3 ++- libassign/src/main/resources/edu/rpi/aris/assign/VERSION | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libaris/src/main/resources/edu/rpi/aris/VERSION b/libaris/src/main/resources/edu/rpi/aris/VERSION index 3eb16890..3a16a46c 100644 --- a/libaris/src/main/resources/edu/rpi/aris/VERSION +++ b/libaris/src/main/resources/edu/rpi/aris/VERSION @@ -1 +1 @@ -0.0.161 +0.0.162 diff --git a/libassign/src/main/java/edu/rpi/aris/assign/message/ClassCreateMsg.java b/libassign/src/main/java/edu/rpi/aris/assign/message/ClassCreateMsg.java index 1e898809..d76b5976 100644 --- a/libassign/src/main/java/edu/rpi/aris/assign/message/ClassCreateMsg.java +++ b/libassign/src/main/java/edu/rpi/aris/assign/message/ClassCreateMsg.java @@ -39,7 +39,7 @@ public String getClassName() { public ErrorType processMessage(@NotNull Connection connection, @NotNull User user, @NotNull ServerPermissions permissions) throws SQLException { try (PreparedStatement insertClass = connection.prepareStatement("INSERT INTO class (name) VALUES(?);"); PreparedStatement selectClassId = connection.prepareStatement("SELECT id FROM class ORDER BY id DESC LIMIT 1;"); - PreparedStatement insertUserClass = connection.prepareStatement("INSERT INTO user_class VALUES(?, ?);")) { + PreparedStatement insertUserClass = connection.prepareStatement("INSERT INTO user_class VALUES(?, ?, ?);")) { insertClass.setString(1, name); insertClass.executeUpdate(); try (ResultSet rs = selectClassId.executeQuery()) { @@ -49,6 +49,7 @@ public ErrorType processMessage(@NotNull Connection connection, @NotNull User us } insertUserClass.setInt(1, user.uid); insertUserClass.setInt(2, cid); + insertUserClass.setInt(3, user.defaultRole.getId()); insertUserClass.executeUpdate(); } return null; diff --git a/libassign/src/main/resources/edu/rpi/aris/assign/VERSION b/libassign/src/main/resources/edu/rpi/aris/assign/VERSION index 3eb16890..3a16a46c 100644 --- a/libassign/src/main/resources/edu/rpi/aris/assign/VERSION +++ b/libassign/src/main/resources/edu/rpi/aris/assign/VERSION @@ -1 +1 @@ -0.0.161 +0.0.162