Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ef90cc9

Browse files
authored
Why base type is citext and not text?
1 parent b027db1 commit ef90cc9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎domains/email.sql‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
CREATE EXTENSION citext;
1+
CREATE EXTENSION IF NOT EXISTS citext;
22

3+
/*
4+
Why base type is citext and not text?
5+
Because email is case insensetive, for example: alex.f@ya.ru = Alex.F@ya.ru.
6+
So we can create unique constraint `alter table my_table add unique (email)`. Not `alter table my_table add unique (lower(email))`.
7+
*/
38
CREATE DOMAIN email AS citext CHECK(
49
octet_length(VALUE) BETWEEN 6 AND 320 -- https://en.wikipedia.org/wiki/Email_address
510
AND VALUE LIKE '_%@_%.__%' -- rough, but quick check email syntax

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /