mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
ingore case when checking name uniqueness
This commit is contained in:
parent
9599c98c77
commit
5651c92efe
2 changed files with 6 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ import { analytics } from '../../utils/analytics'
|
|||
import { env } from '../../env'
|
||||
import { User } from '../../entity/user'
|
||||
import { Label } from '../../entity/label'
|
||||
import { getManager, getRepository } from 'typeorm'
|
||||
import { getManager, getRepository, ILike } from 'typeorm'
|
||||
import { setClaims } from '../../entity/utils'
|
||||
import { Link } from '../../entity/link'
|
||||
import { LinkLabel } from '../../entity/link_label'
|
||||
|
|
@ -76,9 +76,10 @@ export const createLabelResolver = authorized<
|
|||
}
|
||||
}
|
||||
|
||||
// Check if label already exists ignoring case of name
|
||||
const existingLabel = await getRepository(Label).findOne({
|
||||
where: {
|
||||
name,
|
||||
name: ILike(name),
|
||||
},
|
||||
})
|
||||
if (existingLabel) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ BEGIN;
|
|||
|
||||
ALTER TABLE omnivore.labels
|
||||
DROP COLUMN link_id,
|
||||
ADD COLUMN color text NOT NULL,
|
||||
ADD COLUMN color text NOT NULL DEFAULT '#000000',
|
||||
ADD COLUMN description text,
|
||||
ADD CONSTRAINT label_name_unique UNIQUE (user_id, name);
|
||||
|
||||
|
|
@ -18,4 +18,6 @@ CREATE TABLE omnivore.link_labels (
|
|||
UNIQUE (link_id, label_id)
|
||||
);
|
||||
|
||||
GRANT SELECT, INSERT, DELETE ON omnivore.link_labels TO omnivore_user;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
|||
Loading…
Reference in a new issue