Fix note not showing if case mismatch in name
This wouldn't be a problem in the first case, if there was a foreign key connection between note and character tables. Can't add that quite yet though.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
CREATE DATABASE cosmic;
|
||||
CREATE USER cosmic_admin WITH ENCRYPTED PASSWORD 'redsnailshell';
|
||||
CREATE USER cosmic_admin WITH CREATEROLE ENCRYPTED PASSWORD 'redsnailshell';
|
||||
GRANT ALL PRIVILEGES ON DATABASE cosmic TO cosmic_admin;
|
||||
ALTER ROLE cosmic_admin WITH CREATEROLE;
|
||||
@@ -33,18 +33,20 @@ public class NoteDao {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Note> findAllByTo(String to) {
|
||||
public List<Note> findAllByTo(String receiver) {
|
||||
try (Handle handle = connection.getHandle()) {
|
||||
// Using LOWER as a workaround for notes not appearing when being sent to name with wrongly typed casing.
|
||||
// Ideally, the character ids should be the identifier rather than name.
|
||||
return handle.createQuery("""
|
||||
SELECT *
|
||||
FROM note
|
||||
WHERE deleted = 0
|
||||
AND receiver = ?""")
|
||||
.bind(0, to)
|
||||
AND LOWER(receiver) = LOWER(?)""")
|
||||
.bind(0, receiver)
|
||||
.mapTo(Note.class)
|
||||
.list();
|
||||
} catch (JdbiException e) {
|
||||
throw new DaoException("Failed to find notes sent to: %s".formatted(to), e);
|
||||
throw new DaoException("Failed to find notes sent to: %s".formatted(receiver), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,5 @@ CREATE TABLE note(
|
||||
deleted smallint NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
CREATE INDEX note_received_idx ON note(receiver);
|
||||
GRANT SELECT, INSERT, UPDATE ON note TO ${server-username};
|
||||
GRANT USAGE ON note_id_seq TO ${server-username};
|
||||
|
||||
Reference in New Issue
Block a user