Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1giMlc-0003tc-Ug for pgsql-general@arkaria.postgresql.org; Sat, 12 Jan 2019 17:08:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1giMlZ-00061S-ML for pgsql-general@arkaria.postgresql.org; Sat, 12 Jan 2019 17:08:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1giMlY-0005vY-VJ for pgsql-general@lists.postgresql.org; Sat, 12 Jan 2019 17:08:13 +0000 Received: from mail-oln040092004084.outbound.protection.outlook.com ([40.92.4.84] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1giMlQ-0001Ld-4T for pgsql-general@lists.postgresql.org; Sat, 12 Jan 2019 17:08:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Gwtgvnh1GP8Y6E9ZTn3f9fmPmJKW3VZLxub7ubdrMQ=; b=UIpo2vEd+TaJIJsBmvQABsbk1RZk3zyhZS4BaU4Wp0RENI4UrtD56IwOo9HiUEbrH0aq5aM4N25IGcRkhoAuhrkF0gjjo6gPSUHeeS5H9lSCd/f6aYx0ZOksLYqiZkCYtwFZwIsP6yeWVUc77mEE7g3fKKeDGLj1t12J8538r/DtikjBHdpCYlGW+yZPzO5NBDMvM4O8AKH0I07c266r9I5fIewIvGqeMyhWVsNGblM8acmwroIhQv2OGGGboEbAnFDHFMz8nMXngtxch5AF+/U0Z50KUiPj+i7meeMEpAht4YZrV80XAWA9EuAe+Ed0fkEaNY3l9tRaxVZnI7498g== Received: from CY1NAM02FT022.eop-nam02.prod.protection.outlook.com (10.152.74.58) by CY1NAM02HT152.eop-nam02.prod.protection.outlook.com (10.152.75.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1471.13; Sat, 12 Jan 2019 17:08:01 +0000 Received: from SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM (10.152.74.51) by CY1NAM02FT022.mail.protection.outlook.com (10.152.75.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1471.13 via Frontend Transport; Sat, 12 Jan 2019 17:08:01 +0000 Received: from SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM ([fe80::cd74:6b5:766c:1dc2]) by SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM ([fe80::cd74:6b5:766c:1dc2%8]) with mapi id 15.20.1516.019; Sat, 12 Jan 2019 17:08:01 +0000 From: Ricardo Martin Gomez To: "pgsql-general@lists.postgresql.org" , Rich Shepard Subject: Re: insert into: NULL in date column Thread-Topic: insert into: NULL in date column Thread-Index: AQHUqgDpP8mY5QomRUGdtt+JnDIAy6WqsGKAgAAEQoCAAAETAIAAArKAgAAHWACAABMKAIAACgkAgADIoQCAACR8gIAAAhSAgAANdYCAAAGQgIAAA7JT Date: Sat, 12 Jan 2019 17:08:01 +0000 Message-ID: References: <410b055a-24a7-5e15-f4e6-462e64794530@gmail.com> , In-Reply-To: Accept-Language: es-AR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:C71C9DD006DAE62ABE49D56920BD29FE724BB2DE5CFEAC0A9A1550D7C5025622;UpperCasedChecksum:A3D3D7E247585C7A73595FD3A2B5B2B842437D0248C55006E9119105D373D336;SizeAsReceived:7941;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [z6DsLlU6do7YuMcTJlWdfCLl7BPTlrCn] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1NAM02HT152;6:ahqx38pw9YKVB+oP+hbA1lB5ZWDaFT0eFJ+Bu96RAPZe8qlbUodlGt6mskzmn7CtbgHQT8WbMIUkHCqqbRiJRjb+tbBhXxK5A821z3Mg1TyoiWFhRws55dJlmmhg7i/BiGPTA6ihaE5Je1dAH0p8gnb3D0QXSGZJVcU70wR4Rd+aQYNltSIY3FWykQ5NXaGY6+m5q+pL8eH4oMWP2Zb5l+igWdcFMRLFnoeDN6HOOK34oJ8002b+yOfvKHPsvZcNSWGA4i87+GcM9pHUthW2wZwe5aSlsiaLveryZzBErXD31lgEHmAbzp8x52+xEYN7d74Bw3dGxxiEsCmCbLBbXoW/Z2Q/bLRHUQXboHZFMkQH5taDwZASaPqViwqZg9CvfKxUz1TWoQXc/E6EHV5wwL16bWPiD3AAOVzeYekL4Yd3Xe7wNaHM93gScjQYCM8N5KGiAhvmQN2aiDreGuVwng==;5:4kN7bD4gZr7mW/si5j9QwXssMs37uyhNZSikrKvk0dij/vJbxmFB/VOkLKKggXT5a32giXJWtCbl/6Gyiu7VODA4oAoyxd2vFf105F//kSmoPLKRd4EtdBKEkTGAJUxS6QXjd72HUdE1lfWWqCJMALqBlRZZdJHHe1kI1j4/jzE=;7:PFY7hyKXlhfEJpqLrETzJgADtzwXm0TmlAwidZhLFPYTsSiZvSRUIw7gfrBhCqPCAKb8GtZpILD9tKhJ9A/Pmnb8PwBpeZDBny3zUOWK395C9aTwprB/gFKedx5oQSwpXeT4FAD0P8tZy/dIAv+Izg== x-incomingheadercount: 46 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045);SRVR:CY1NAM02HT152; x-ms-traffictypediagnostic: CY1NAM02HT152: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(4566010)(82015058);SRVR:CY1NAM02HT152;BCL:0;PCL:0;RULEID:;SRVR:CY1NAM02HT152; x-microsoft-antispam-message-info: cH2l3rRKCcI2X5droZbXYf6k+No1CXQpf52q2XrURFTjS6ZximHoDcbq853lGkXG Content-Type: multipart/alternative; boundary="_000_SC1P15201MB2304F4D19BA7554AC517794AA3860SC1P15201MB2304_" MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: f12efbb0-867f-4c93-8261-502eceebfafa X-MS-Exchange-CrossTenant-Network-Message-Id: cb60c4d5-0406-4d8c-0ad5-08d678b08253 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: f12efbb0-867f-4c93-8261-502eceebfafa X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jan 2019 17:08:01.4510 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT152 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_SC1P15201MB2304F4D19BA7554AC517794AA3860SC1P15201MB2304_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 ________________________________ From: Rich Shepard 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 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 " 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. Afte= r > 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 da= te might not be if there's nothing scheduled. Best regards, Rich --_000_SC1P15201MB2304F4D19BA7554AC517794AA3860SC1P15201MB2304_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
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


From: Rich Shepard <rs= hepard@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<= br> > 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 a= ctually 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&g= t;"

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. A= fter
> which the constraint fails - but you are INFORMED ONLY IF THE RECORD I= S
> INSERTED AGAIN. So basically you will not see a problem until you atte= mpt
> to restore your data on some future date and much of your data fails t= o
> 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


--_000_SC1P15201MB2304F4D19BA7554AC517794AA3860SC1P15201MB2304_--