[extbp] False positive check constraint
authorVíctor Martínez Romanos <victor.martinez@openbravo.com>
Tue, 09 Jun 2020 16:37:24 +0200
changeset 970 d40535f8484a
parent 969 d2830c4e4a99
child 971 1f1913bacd42
[extbp] False positive check constraint

The check constraint addition is a false positive because by default the new columns have the following values:
C_EXTBP_ENABLED = 'N'
C_EXTBP_CONFIG_ID IS NULL

So the new check constraint AD_CLIENTINFO_EXTBPCONF_CH is always fulfilled for existing records
model/src-db/database/model/tables/AD_CLIENTINFO.xml
--- a/model/src-db/database/model/tables/AD_CLIENTINFO.xml	Thu Jun 04 19:19:48 2020 +0200
+++ b/model/src-db/database/model/tables/AD_CLIENTINFO.xml	Tue Jun 09 16:37:24 2020 +0200
@@ -165,6 +165,14 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="C_EXTBP_ENABLED" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
+      </column>
+      <column name="C_EXTBP_CONFIG_ID" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="AD_CLIENT_CLIENTINFO">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
@@ -240,6 +248,9 @@
       <foreign-key foreignTable="AD_TREE" name="AD_CLIENTINFO_TREE_USER2">
         <reference local="AD_TREE_USER2_ID" foreign="AD_TREE_ID"/>
       </foreign-key>
+      <foreign-key foreignTable="C_EXTBP_CONFIG" name="C_CLINFO_EXTBPCONF_FK">
+        <reference local="C_EXTBP_CONFIG_ID" foreign="C_EXTBP_CONFIG_ID"/>
+      </foreign-key>
       <foreign-key foreignTable="C_UOM" name="C_UOM_LENGTH_AD_CLIENTINFO">
         <reference local="C_UOM_LENGTH_ID" foreign="C_UOM_ID"/>
       </foreign-key>
@@ -257,6 +268,8 @@
       <check name="AD_CLIENTINFO_ALLOWNEGATIV_CHK"><![CDATA[ALLOWNEGATIVESTOCK IN ('Y', 'N')]]></check>
       <check name="AD_CLIENTINFO_CHECKINOUTOR_CHK"><![CDATA[CHECKINOUTORG IN ('Y', 'N')]]></check>
       <check name="AD_CLIENTINFO_CHECKORDEROR_CHK"><![CDATA[CHECKORDERORG IN ('Y', 'N')]]></check>
+      <check name="AD_CLIENTINFO_EXTBPCONF_CH"><![CDATA[C_EXTBP_ENABLED = 'N' AND C_EXTBP_CONFIG_ID IS NULL OR C_EXTBP_ENABLED = 'Y' AND C_EXTBP_CONFIG_ID IS NOT NULL]]></check>
+      <check name="AD_CLIENTINFO_EXTBPENABL_CH"><![CDATA[C_EXTBP_ENABLED IN ('Y', 'N')]]></check>
       <check name="AD_CLIENTINFO_ISACTIVE_CHK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
       <check name="AD_CLIENTINFO_ISDISCOUNTLI_CHK"><![CDATA[ISDISCOUNTLINEAMT IN ('Y', 'N')]]></check>
     </table>