Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/io/supertokens/storage/postgresql/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -1540,12 +1540,12 @@ public boolean deleteRoleForUser_Transaction(TransactionConnection con, String u
}

@Override
public void createNewRoleOrDoNothingIfExists_Transaction(TransactionConnection con, String role)
public boolean createNewRoleOrDoNothingIfExists_Transaction(TransactionConnection con, String role)
throws StorageQueryException {
Connection sqlCon = (Connection) con.getConnection();

try {
UserRolesQueries.createNewRole_Transaction(this, sqlCon, role);
return UserRolesQueries.createNewRoleOrDoNothingIfExists_Transaction(this, sqlCon, role);
} catch (SQLException e) {
throw new StorageQueryException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ public static String getQueryToCreateUserRolesRoleIndex(Start start) {
return "CREATE INDEX user_roles_role_index ON " + getConfig(start).getUserRolesTable() + "(role);";
}

public static void createNewRole_Transaction(Start start, Connection con, String role)
public static boolean createNewRoleOrDoNothingIfExists_Transaction(Start start, Connection con, String role)
throws SQLException, StorageQueryException {
String QUERY = "INSERT INTO " + getConfig(start).getRolesTable() + " VALUES(?) ON CONFLICT DO NOTHING;";
update(con, QUERY, pst -> pst.setString(1, role));
int rowsUpdated = update(con, QUERY, pst -> pst.setString(1, role));
return rowsUpdated > 0;
}

public static void addPermissionToRoleOrDoNothingIfExists_Transaction(Start start, Connection con, String role,
Expand Down