From 3c5cfe677e013e0bcf10d168c08ac37a93482583 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 22 Dec 2022 21:42:30 +0300 Subject: User nick is case-insensitive --- src/main/resources/db/specific/h2/V1.26__case_insensitive_nick.sql | 1 + .../resources/db/specific/postgresql/V1.26__case_insensitive_nick.sql | 1 + src/test/java/com/juick/server/tests/ServerTests.java | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/specific/h2/V1.26__case_insensitive_nick.sql create mode 100644 src/main/resources/db/specific/postgresql/V1.26__case_insensitive_nick.sql (limited to 'src') diff --git a/src/main/resources/db/specific/h2/V1.26__case_insensitive_nick.sql b/src/main/resources/db/specific/h2/V1.26__case_insensitive_nick.sql new file mode 100644 index 00000000..3b17aa00 --- /dev/null +++ b/src/main/resources/db/specific/h2/V1.26__case_insensitive_nick.sql @@ -0,0 +1 @@ +ALTER TABLE users ALTER COLUMN nick SET DATA TYPE VARCHAR_IGNORECASE(64) diff --git a/src/main/resources/db/specific/postgresql/V1.26__case_insensitive_nick.sql b/src/main/resources/db/specific/postgresql/V1.26__case_insensitive_nick.sql new file mode 100644 index 00000000..a68c15f3 --- /dev/null +++ b/src/main/resources/db/specific/postgresql/V1.26__case_insensitive_nick.sql @@ -0,0 +1 @@ +ALTER TABLE users ALTER COLUMN nick TYPE character varying(64) COLLATE case_insensitive diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 6eae82f3..54cffbd4 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -478,7 +478,7 @@ public class ServerTests { Message msg2 = messagesService.getMessage(mid2).get(); assertEquals(1, msg2.getTags().size()); Exception exc = assertThrows(UsernameTakenException.class, () -> { - userService.createUser("ugnich", "x"); + userService.createUser("ugnicH", "x"); }); assertEquals("Username taken", exc.getMessage()); User hugnich = userService.createUser("hugnich", "x").orElseThrow(IllegalStateException::new); -- cgit v1.2.3