这是indexloc提供的服务,不要输入任何密码
Skip to content

Add citext table column type #2038

@RodolfoSilva

Description

@RodolfoSilva

Imagine we have the following table:

CREATE TABLE users (  
  id     uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
  email  text
);

If we want to ensure that each user has a unique email we simply add:

ALTER TABLE users ADD CONSTRAINT email_unique UNIQUE (email);

If we try it out by inserting some data:

INSERT INTO users (email) VALUES ('test@example.com');  
INSERT INTO users (email) VALUES ('test@example.com');

ERROR:  duplicate key value violates unique constraint "email_unique"  
DETAIL:  Key (email)=(test@example.com) already exists. 

But if we try insert the same email with upper case:

INSERT INTO users (email) VALUES ('TEST@example.com');

SELECT * from users;

                  id                  |      email       
--------------------------------------+------------------
 de624d84-63a3-11e9-a923-1681be663d3e | test@example.com
 0c4b25af-5736-4985-9b4c-bdfebd04694d | TEST@example.com

I think this can be part of the hasura console.

cc\ @0x777 @dsandip @wawhal

Metadata

Metadata

Assignees

Labels

c/consoleRelated to consolep/highcandidate for being included in the upcoming sprints/wipStatus: This issue is a work in progress

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions