Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0049897Openbravo ERPY. DBSourceManagerpublic2022-07-28 13:192022-11-18 09:23
shuehner 
alostale 
normalmajorhave not tried
closedfixed 
5
 
PR22Q4PR22Q4 
Core
No
0049897: Add missing support for referencing other columns in onCreateDefault during importsampledata
onCreateDefault support sql-expressions on top of just fixed constant literals.

That is fully implemented during update.database.

However this logic used during import.sampledata currently only supports constant literals.

We should add support for at least one common case which is referencing another column of the same table (to copy the data from).

Example snippet for a module adding such a column to M_LOCATOR table.

      <column name="NEW_COLUMN_CODE" primaryKey="false" required="true" type="NVARCHAR" size="40" autoIncrement="false">
        <default/>
        <onCreateDefault><![CDATA[VALUE]]></onCreateDefault>
      </column>

Add a new required column to an existing table with definition shown above (i.e. table M_LOCATOR)
Do NOT modify sampledata to contain data for the new column.
Run install.source and observe not-null constraint violation for the new column.
Add code to existing logic supporting 'onCreateDefault for not null column during import.sampledata' to detect:
- Referencing another column on the same table
- Replace column reference by 'value' of that other column planned to be inserted.

No tags attached.
related to defect 0046647 closed alostale Neither onCreateDefault nor default values are used when inserting sampledata 
related to feature request 0050951 closed caristu onCreateDefault not working for non mandatory columns referencing same table 
Issue History
2022-07-28 13:19shuehnerNew Issue
2022-07-28 13:19shuehnerAssigned To => Triage Platform Base
2022-07-28 13:19shuehnerModules => Core
2022-07-28 13:19shuehnerTriggers an Emergency Pack => No
2022-07-28 13:20shuehnerNote Added: 0139668
2022-07-28 14:27hgbotNote Added: 0139678
2022-08-01 09:03AugustoMauchAssigned ToTriage Platform Base => alostale
2022-08-01 09:03AugustoMauchStatusnew => scheduled
2022-08-11 13:09hgbotNote Added: 0140062
2022-08-11 13:10hgbotResolutionopen => fixed
2022-08-11 13:10hgbotStatusscheduled => closed
2022-08-11 13:10hgbotNote Added: 0140063
2022-08-11 13:10hgbotFixed in Version => PR22Q4
2022-08-11 13:10hgbotNote Added: 0140064
2022-08-11 13:10hgbotNote Added: 0140065
2022-08-11 13:10hgbotNote Added: 0140066
2022-11-18 09:23caristuRelationship addedrelated to 0046647
2022-11-18 13:41caristuRelationship addedrelated to 0050951

Notes
(0139668)
shuehner   
2022-07-28 13:20   
Adding short due-date as discussed between ALO/SHU
(0139678)
hgbot   
2022-07-28 14:27   
Merge Request created: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/33 [^]
(0140062)
hgbot   
2022-08-11 13:09   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/679 [^]
(0140063)
hgbot   
2022-08-11 13:10   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/679 [^]
(0140064)
hgbot   
2022-08-11 13:10   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 594166468e5cd20dcc0b116a8cca822ec1bdc967
Author: Augusto Mauch <augusto.mauch@openbravo.com>
Date: 11-08-2022 13:08:53
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/594166468e5cd20dcc0b116a8cca822ec1bdc967 [^]

Fixes ISSUE-49897: import sample data fails with OCD referencing a column

---
M src-db/database/lib/dbsourcemanager.jar
---
(0140065)
hgbot   
2022-08-11 13:10   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/dbsm [^]
Changeset: 1984dc6f1bcbd78eb33e445ce1518cd763872d33
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 28-07-2022 14:23:03
URL: https://gitlab.com/openbravo/product/dbsm/-/commit/1984dc6f1bcbd78eb33e445ce1518cd763872d33 [^]

fixes BUG-49897: import sample data fails with OCD referencing a column

If a mandatory column has an onCreateDefault consisting on an expression
that simply references another column in that same table and sampledata
with no value for that column is applied, it fails because only literal
onCreateDefault are applied in this case.

The logic has been extended to cover this case (not including
recursivity), now the value of the referenced column is applied.

---
A src-test/data/sampledata/REFERENCE_CREATEDEFAULT.xml
A src-test/model/sampledata/SAMPLE_DATA_MODEL2.xml
M src-test/src/org/openbravo/dbsm/test/sampledata/ImportSampleData.java
M src/org/apache/ddlutils/io/DataToDatabaseSink.java
M src/org/apache/ddlutils/model/Column.java
---
(0140066)
hgbot   
2022-08-11 13:10   
Merge request merged: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/33 [^]