Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0008096Openbravo ERPY. DBSourceManagerpublic2009-03-12 15:492009-03-26 17:40
rafaroda 
marvintm 
immediatemajoralways
closedfixed 
20Ubuntu 7.10
2.40 
2.40MP4 
Core
No
0008096: DBSourceManager: Constraint enabling should be done after onCreateDefault
DBSourceManager should enable new constraints after executing onCreateDefault and not before.
1) Create a new column in a XML table file with an onCreateDefault. For instance, in M_INOUT add:
<column name="FREIGHT_CURRENCY_ID" primaryKey="false" required="false" type="DECIMAL" size="10,0" autoIncrement="false">
        <default/>
        <onCreateDefault><![CDATA[SELECT C_ACCTSCHEMA.C_CURRENCY_ID FROM C_ACCTSCHEMA, AD_CLIENTINFO, AD_CLIENT WHERE AD_CLIENTINFO.C_ACCTSCHEMA1_ID = C_ACCTSCHEMA.C_ACCTSCHEMA_ID AND AD_CLIENT.AD_CLIENT_ID = AD_CLIENTINFO.AD_CLIENT_ID AND AD_CLIENT.AD_CLIENT_ID = M_INOUT.AD_CLIENT_ID]]></onCreateDefault>
      </column>
 <foreign-key foreignTable="C_CURRENCY" name="CCURRENCY_MINOUT">
        <reference local="FREIGHT_CURRENCY_ID" foreign="C_CURRENCY_ID"/>
      </foreign-key>

2) Create a new check constraint in this same XML table.
<check name="M_INOUT_CURRENCY_CHECK"><![CDATA[(FREIGHTAMT IS NULL) OR (FREIGHT_CURRENCY_ID IS NOT NULL)]]></check>

3) Execute: ant update.database.structure
[alterdatabase] SQL Command failed with: ERROR: check constraint "m_inout_currency_check" is violated by some row
[alterdatabase] ALTER TABLE M_INOUT
[alterdatabase] ADD CONSTRAINT M_INOUT_CURRENCY_CHECK CHECK ((FREIGHTAMT IS NULL) OR (FREIGHT_CURRENCY_ID IS NOT NULL))

DBSourceManager should enable new constraints after executing onCreateDefault.
No tags attached.
blocks defect 0008095 closed marvintm DBSourceManager: Constraint enabling should be done after onCreateDefault 
blocks backport 0007957 closed rafaroda Multi currency issues in some processes and tables 
Issue History
2009-03-12 15:50rafarodaTypedefect => backport
2009-03-12 15:50rafarodafix_in_branch => 2.40
2009-03-12 15:51rafarodaNote Added: 0014612
2009-03-12 15:51rafarodaPriorityhigh => immediate
2009-03-12 15:51rafarodaRelationship addedblocks 0007957
2009-03-12 15:52rafarodaProposed Solution updated
2009-03-12 16:36rafarodaNote Edited: 0014612
2009-03-12 17:18hgbotCheckin
2009-03-12 17:18hgbotNote Added: 0014619
2009-03-12 17:18hgbotStatusscheduled => resolved
2009-03-12 17:18hgbotResolutionopen => fixed
2009-03-12 17:20hgbotCheckin
2009-03-12 17:20hgbotNote Added: 0014620
2009-03-12 17:20hgbotFixed in SCM revision => http://code.openbravo.com/erp/stable/2.40/rev/5fb560290c79acef7ce219f5322faa355fb531f3 [^]
2009-03-24 11:01psarobeFixed in Version => 2.40MP4
2009-03-26 17:40psarobeStatusresolved => closed

Notes
(0014612)
rafaroda   
2009-03-12 15:51   
(edited on: 2009-03-12 16:36)
Changed priority to immediate since it blocks immediate backport 0007957

(0014619)
hgbot   
2009-03-12 17:18   
Repository: dbsourcemanager
Revision: 257
Author: marvintm
Date: 2009-03-12 17:18:33 +0100 (Thu, 12 Mar 2009)

Fixed issue 8096. OnCreateDefaults should now be executed before any check or unique constraints.

---
U branches/r0.8x/src/org/apache/ddlutils/platform/SqlBuilder.java
---

https://dev.openbravo.com/websvn/dbsourcemanager/?rev=257&sc=1 [^]
(0014620)
hgbot   
2009-03-12 17:20   
Repository: erp/stable/2.40
Changeset: 5fb560290c79acef7ce219f5322faa355fb531f3
Author: Antonio Moreno <antonio.moreno <at> openbravo.com>
Date: Thu Mar 12 17:23:27 2009 +0100
URL: http://code.openbravo.com/erp/stable/2.40/rev/5fb560290c79acef7ce219f5322faa355fb531f3 [^]

Fixed issue 8096. OnCreateDefaults should now be executed before any check or unique constraints.

---
M src-db/database/lib/dbsourcemanager.jar
---