pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ricardo Martin Gomez <rimartingomez@hotmail.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
To: Rich Shepard <rshepard@appl-ecosys.com>
Subject: Re: insert into: NULL in date column
Date: Sat, 12 Jan 2019 17:08:01 +0000
Message-ID: <SC1P15201MB2304F4D19BA7554AC517794AA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <alpine.LNX.2.20.1901120851430.10285@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.1901111449480.8922@salmo.appl-ecosys.com>
	<410b055a-24a7-5e15-f4e6-462e64794530@gmail.com>
	<alpine.LNX.2.20.1901111518170.8922@salmo.appl-ecosys.com>
	<cc5fb963-ea67-0068-8158-04a190f16242@gmail.com>
	<CAD3a31Vh9y8QirWXU5TPD_XgaquMqXYfnK1PMOCOntyESp=yGw@mail.gmail.com>
	<alpine.LNX.2.20.1901111557460.8922@salmo.appl-ecosys.com>
	<e0422166-f9ad-4754-eb98-4fcfcce36d9d@aklaver.com>
	<SC1P15201MB230471B7A1936DDD1652766BA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM>
	<alpine.LNX.2.20.1901120541250.10285@salmo.appl-ecosys.com>
	<CAKFQuwYmB8Htt5rD3ChN9=kgOZOwvA=8aUuoTrPO50t7pz1n0Q@mail.gmail.com>
	<alpine.LNX.2.20.1901120800140.10285@salmo.appl-ecosys.com>
	<CAKFQuwZ-cPmXmBNG27d293qKPv=OmgZmH_srztvtBbzhVHcMkw@mail.gmail.com>
	<alpine.LNX.2.20.1901120851430.10285@salmo.appl-ecosys.com>

Hi,
In MYSQL Null date is equal '01/01/1900' or '01/01/1970', I don't remember but you can also use the same logic for the check_constraint.
Regards

Obtener Outlook para Android<https://aka.ms/ghei36;

________________________________
From: Rich Shepard <rshepard@appl-ecosys.com>
Sent: Saturday, January 12, 2019 1:54:47 PM
To: pgsql-general@lists.postgresql.org
Subject: Re: insert into: NULL in date column

On Sat, 12 Jan 2019, David G. Johnston wrote:

> NULL isn't the problem - a check constraint can resolve to unknown in
> which case it behaves the same as if it resolved as true (i.e., its
> basically a <check> IS NOT FALSE test in the backend). This is actually a
> nice feature of check constraints since for nullable columns you don't
> have to write "col IS NULL OR <the check I really care about>"

David,

   Thanks for correcting me.

> The problem is that check constraints are only applied at time of data
> change. If you insert a record whose date is 3 days from now the check
> constraint passes today and (in theory) for the next couple of days. After
> which the constraint fails - but you are INFORMED ONLY IF THE RECORD IS
> INSERTED AGAIN. So basically you will not see a problem until you attempt
> to restore your data on some future date and much of your data fails to
> restore because those dates are no longer in the future.

   I thought that the check constraint applied at data entry, too. If not,
then I'll have either wxPython or SQLAlchemy ensure that the next_contact
date is later than the contact date.

> If you want to check for a future date you should probably also store the
> date you are comparing against and have the check constraint reference
> both fields.

   The contact date is always entered in a new row, but the next_contact date
might not be if there's nothing scheduled.

Best regards,

Rich

view thread (23+ messages)  latest in thread

Message-ID: <SC1P15201MB2304F4D19BA7554AC517794AA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM>
Permalink:  ../SC1P15201MB2304F4D19BA7554AC517794AA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/SC1P15201MB2304F4D19BA7554AC517794AA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: rimartingomez@hotmail.com, rshepard@appl-ecosys.com
  Subject: Re: insert into: NULL in date column
  In-Reply-To: <SC1P15201MB2304F4D19BA7554AC517794AA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM>
  References: <alpine.LNX.2.20.1901111449480.8922@salmo.appl-ecosys.com> <410b055a-24a7-5e15-f4e6-462e64794530@gmail.com> <alpine.LNX.2.20.1901111518170.8922@salmo.appl-ecosys.com> <cc5fb963-ea67-0068-8158-04a190f16242@gmail.com> <CAD3a31Vh9y8QirWXU5TPD_XgaquMqXYfnK1PMOCOntyESp=yGw@mail.gmail.com> <alpine.LNX.2.20.1901111557460.8922@salmo.appl-ecosys.com> <e0422166-f9ad-4754-eb98-4fcfcce36d9d@aklaver.com> <SC1P15201MB230471B7A1936DDD1652766BA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM> <alpine.LNX.2.20.1901120541250.10285@salmo.appl-ecosys.com> <CAKFQuwYmB8Htt5rD3ChN9=kgOZOwvA=8aUuoTrPO50t7pz1n0Q@mail.gmail.com> <alpine.LNX.2.20.1901120800140.10285@salmo.appl-ecosys.com> <CAKFQuwZ-cPmXmBNG27d293qKPv=OmgZmH_srztvtBbzhVHcMkw@mail.gmail.com> <alpine.LNX.2.20.1901120851430.10285@salmo.appl-ecosys.com> <SC1P15201MB2304F4D19BA7554AC517794AA3860@SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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