Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Jitendra Loyal
Thanks Laurenz This is interesting...b is True Thanks and regards, Jitendra On Wed 11 Nov, 2020, 22:52 Laurenz Albe, wrote: > On Wed, 2020-11-11 at 11:47 +0100, Tomas Vondra wrote: > > you may do this, for example: > > > > (b it not null and b = true) and (c is not null) > > > > Or somethi

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Laurenz Albe
On Wed, 2020-11-11 at 11:47 +0100, Tomas Vondra wrote: > you may do this, for example: > > (b it not null and b = true) and (c is not null) > > Or something like that. My (equivalent) suggestion: b IS TRUE AND c IS NOT NULL Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgre

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Jitendra Loyal
Thanks Tomas Understood... My bad Was just not looking at that aspect Thanks once again, Regards, Jitendra On Wed, 11 Nov 2020 at 16:17, Tomas Vondra wrote: > > On 11/11/20 10:06 AM, Jitendra Loyal wrote: > > Thanks Nikolay > > > > I read that but is there a way to meet the above requ

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Tomas Vondra
On 11/11/20 10:06 AM, Jitendra Loyal wrote: > Thanks Nikolay > > I read that but is there a way to meet the above requirement. And I will > like to add that IS NULL and IS NOT NULL should evaluate to true/false. > These operators are made for this and should not be returning NULL. > This has n

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Alban Hertroys
On 11 Nov 2020, at 11:15, Jitendra Loyal wrote: > >  > Thanks Nikolay > > I read that but is there a way to meet the above requirement. And I will like > to add that IS NULL and IS NOT NULL should evaluate to true/false. These > operators are made for this and should not be returning NULL.

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Jitendra Loyal
Thanks Nikolay I read that but is there a way to meet the above requirement. And I will like to add that IS NULL and IS NOT NULL should evaluate to true/false. These operators are made for this and should not be returning NULL. Regards, Jitendra On Wed 11 Nov, 2020, 14:18 Nikolay Samokhvalov, w

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Nikolay Samokhvalov
On Wed, Nov 11, 2020 at 12:26 AM Jitendra Loyal wrote: > Despite the above two constraints, the following rows get into the table: > insert into t (b , c) values (null, true), (null, false); > This behavior is described in the docs https://www.postgresql.org/docs/current/ddl-constraints.htm

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Pavel Stehule
st 11. 11. 2020 v 9:38 odesílatel Chris Sterritt napsal: > > On 11/11/2020 06:44, Jitendra Loyal wrote: > > Consider this table definition: > create table t ( i serial, b bool, c bool, > constraint b_c check ( (b = true and c is > not null ) or (b is disti

Re: Check constraints do not seem to be working!!!

2020-11-11 Thread Chris Sterritt
On 11/11/2020 06:44, Jitendra Loyal wrote: Consider this table definition:  create table t ( i serial, b bool, c bool,                       constraint b_c check ( (b = true and c is not null ) or (b is distinct from true and c is null) )                       constraint b_c check ( (b = true

Check constraints do not seem to be working!!!

2020-11-11 Thread Jitendra Loyal
Consider this table definition: create table t ( i serial, b bool, c bool, constraint b_c check ( (b = true and c is not null ) or (b is distinct from true and c is null) ) constraint b_c check ( (b = true and c is not null )