pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedRobust ways for checking allowed values in a column
6+ messages / 5 participants
[nested] [flat]
* Robust ways for checking allowed values in a column
@ 2022-01-25 13:55 Shaozhong SHI <shishaozhong@gmail.com>
2022-01-25 14:16 ` Re: Robust ways for checking allowed values in a column Guillaume Lelarge <guillaume@lelarge.info>
2022-01-25 14:25 ` Re: Robust ways for checking allowed values in a column David G. Johnston <david.g.johnston@gmail.com>
2022-01-25 14:26 ` Re: Robust ways for checking allowed values in a column Ray O'Donnell <ray@rodonnell.ie>
0 siblings, 3 replies; 6+ messages in thread
From: Shaozhong SHI @ 2022-01-25 13:55 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
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?
Regards,
David
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Robust ways for checking allowed values in a column
2022-01-25 13:55 Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-25 14:16 ` Guillaume Lelarge <guillaume@lelarge.info>
2 siblings, 0 replies; 6+ messages in thread
From: Guillaume Lelarge @ 2022-01-25 14:16 UTC (permalink / raw)
To: Shaozhong SHI <shishaozhong@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Le mar. 25 janv. 2022 à 14:56, Shaozhong SHI <shishaozhong@gmail.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.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Robust ways for checking allowed values in a column
2022-01-25 13:55 Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-25 14:25 ` David G. Johnston <david.g.johnston@gmail.com>
2022-01-25 16:35 ` Re: Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
2 siblings, 1 reply; 6+ messages in thread
From: David G. Johnston @ 2022-01-25 14:25 UTC (permalink / raw)
To: Shaozhong SHI <shishaozhong@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
On Tue, Jan 25, 2022 at 6:56 AM Shaozhong SHI <shishaozhong@gmail.com>
wrote:
> select form from mytable where form ~
> '^Canal$|^Drain$|^Foreshore$|^inlandRiver$|^Lake$|^lockOrFlightOfLocks$|^Marsh$|^Researvoir$|^Sea$|^tidalRiver$|^Transfer$'
>
You do not need to repeat the boundary metacharacters on each branch. You
can assert their presence just once and then use parentheses to group the
alternations.
form ~ '^(?Canal|Drain|etc...)$'
David J.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Robust ways for checking allowed values in a column
2022-01-25 13:55 Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
2022-01-25 14:25 ` Re: Robust ways for checking allowed values in a column David G. Johnston <david.g.johnston@gmail.com>
@ 2022-01-25 16:35 ` Shaozhong SHI <shishaozhong@gmail.com>
2022-01-25 16:40 ` Re: Robust ways for checking allowed values in a column Rob Sargent <robjsargent@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Shaozhong SHI @ 2022-01-25 16:35 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
How about adding null as an alteration.
Would this be robust?
Regards,
David
On Tue, 25 Jan 2022 at 14:25, David G. Johnston <david.g.johnston@gmail.com>
wrote:
> On Tue, Jan 25, 2022 at 6:56 AM Shaozhong SHI <shishaozhong@gmail.com>
> wrote:
>
>> select form from mytable where form ~
>> '^Canal$|^Drain$|^Foreshore$|^inlandRiver$|^Lake$|^lockOrFlightOfLocks$|^Marsh$|^Researvoir$|^Sea$|^tidalRiver$|^Transfer$'
>>
>
> You do not need to repeat the boundary metacharacters on each branch. You
> can assert their presence just once and then use parentheses to group the
> alternations.
>
> form ~ '^(?Canal|Drain|etc...)$'
>
> David J.
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Robust ways for checking allowed values in a column
2022-01-25 13:55 Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
2022-01-25 14:25 ` Re: Robust ways for checking allowed values in a column David G. Johnston <david.g.johnston@gmail.com>
2022-01-25 16:35 ` Re: Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-25 16:40 ` Rob Sargent <robjsargent@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Rob Sargent @ 2022-01-25 16:40 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 1/25/22 09:35, Shaozhong SHI wrote:
> How about adding null as an alteration.
>
> Would this be robust?
>
> Regards,
>
> David
>
> On Tue, 25 Jan 2022 at 14:25, David G. Johnston
> <david.g.johnston@gmail.com> wrote:
>
> On Tue, Jan 25, 2022 at 6:56 AM Shaozhong SHI
> <shishaozhong@gmail.com> wrote:
>
> select form from mytable where form ~
> '^Canal$|^Drain$|^Foreshore$|^inlandRiver$|^Lake$|^lockOrFlightOfLocks$|^Marsh$|^Researvoir$|^Sea$|^tidalRiver$|^Transfer$'
>
>
> You do not need to repeat the boundary metacharacters on each
> branch. You can assert their presence just once and then use
> parentheses to group the alternations.
>
> form ~ '^(?Canal|Drain|etc...)$'
>
> David J.
>
You would need to add form ~ 'expression' or form is null
And a body of held water is a reservoir (no 'a')
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Robust ways for checking allowed values in a column
2022-01-25 13:55 Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-25 14:26 ` Ray O'Donnell <ray@rodonnell.ie>
2 siblings, 0 replies; 6+ messages in thread
From: Ray O'Donnell @ 2022-01-25 14:26 UTC (permalink / raw)
To: Shaozhong SHI <shishaozhong@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>
On 25/01/2022 13:55, Shaozhong SHI wrote:
> 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?
Sounds like a candidate for a foreign key relationship.
Ray.
--
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-01-25 16:40 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 13:55 Robust ways for checking allowed values in a column Shaozhong SHI <shishaozhong@gmail.com>
2022-01-25 14:16 ` Guillaume Lelarge <guillaume@lelarge.info>
2022-01-25 14:25 ` David G. Johnston <david.g.johnston@gmail.com>
2022-01-25 16:35 ` Shaozhong SHI <shishaozhong@gmail.com>
2022-01-25 16:40 ` Rob Sargent <robjsargent@gmail.com>
2022-01-25 14:26 ` Ray O'Donnell <ray@rodonnell.ie>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox