Re: Robust ways for checking allowed values in a column

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Robust ways for checking allowed values in a column
Date: 2022-01-25 14:16:06
Message-ID: CAECtzeUk=t2VvDcL=dejPxFsoVKXRtTUzp0w9sTMeVjquL6LXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le mar. 25 janv. 2022 à 14:56, Shaozhong SHI <shishaozhong(at)gmail(dot)com> a
écrit :

> I tried the following:
>
> select form from mytable where form ~
> '^Canal$|^Drain$|^Foreshore$|^inlandRiver$|^Lake$|^lockOrFlightOfLocks$|^Marsh$|^Researvoir$|^Sea$|^tidalRiver$|^Transfer$'
>
> I used ^ and $ to ensure checking of allowed values.
>
> However, 'Backyard' was selected.
>
> Why is that?
>
>
It works for me:

# select 'Backyard' ~
'^Canal$|^Drain$|^Foreshore$|^inlandRiver$|^Lake$|^lockOrFlightOfLocks$|^Marsh$|^Researvoir$|^Sea$|^tidalRiver$|^Transfer$';
┌──────────┐
│ ?column? │
├──────────┤
│ f │
└──────────┘
(1 row)

So you will probably need a complete and reproducible example so that we
could test it.

--
Guillaume.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-01-25 14:25:04 Re: Robust ways for checking allowed values in a column
Previous Message Shaozhong SHI 2022-01-25 13:55:54 Robust ways for checking allowed values in a column