case insensitive names

This commit is contained in:
keyan 2021-09-02 17:22:00 -05:00
parent bf6b2befde
commit 38ba31f2b4
4 changed files with 40 additions and 30 deletions

View File

@ -45,7 +45,7 @@ export default {
let notifications = await models.$queryRaw(`
SELECT ${ITEM_FIELDS}, "Item".created_at as "sortTime", NULL as "earnedSats",
false as mention
From "Item"
FROM "Item"
JOIN "Item" p ON "Item"."parentId" = p.id
WHERE p."userId" = $1
AND "Item"."userId" <> $1 AND "Item".created_at <= $2

View File

@ -14,7 +14,7 @@ export default {
throw new AuthenticationError('you must be logged in')
}
return me.name === name || !(await models.user.findUnique({ where: { name } }))
return me.name?.toUpperCase() === name?.toUpperCase() || !(await models.user.findUnique({ where: { name } }))
},
recentlyStacked: async (parent, args, { models, me }) => {
if (!me) {

View File

@ -0,0 +1,10 @@
/*
Warnings:
- A unique constraint covering the columns `[name]` on the table `users` will be added. If there are existing duplicate values, this will fail.
*/
CREATE EXTENSION IF NOT EXISTS citext;
-- AlterTable
ALTER TABLE users ALTER COLUMN name TYPE citext;

View File

@ -14,7 +14,7 @@ model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
name String? @unique
name String? @unique @db.Citext
email String? @unique
emailVerified DateTime? @map(name: "email_verified")
image String?