Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0046647Openbravo ERPY. DBSourceManagerpublic2021-05-12 15:582021-06-04 11:47
marvintm 
alostale 
normalminoralways
closedfixed 
5
 
PR21Q3 
Core
No
0046647: Neither onCreateDefault nor default values are used when inserting sampledata
Currently, neither onCreateDefault nor default values are used when inserting sampledata, for mandatory columns in client/org records.

This means that sampledata import is currently quite fragile, because if later on a new module adding a mandatory column is installed, the same sampledata cannot be used unless the data definition is updated with values for that column.

It currently also impacts us in the development of the new POS, because we are trying to use the same sampledata we had in the old POS, and we also want to add mandatory columns (with their corresponding default) to the new POS modules.
- Create some sampledata records for a set of modules
- Install a new module which adds a mandatory column with a default/oncreatedefault value.
- Do install.source. Realise that it fails because the record is being inserted without value in this mandatory column.
Probably either oncreatedefault or default should be used, if when inserting a record the value of a column is null, the column is mandatory, and it contains a default or oncreatedefault.

Most probably the behaviour we have for sourcedata should be replicated here. Originally, oncreatedefault value was used for this, but this may have changed in recent years.
No tags attached.
related to defect 0049897PR22Q4 closed alostale Add missing support for referencing other columns in onCreateDefault during importsampledata 
Issue History
2021-05-12 15:58marvintmNew Issue
2021-05-12 15:58marvintmAssigned To => platform
2021-05-12 15:58marvintmModules => Core
2021-05-12 15:58marvintmTriggers an Emergency Pack => No
2021-05-25 16:00shuehnerIssue Monitored: shuehner
2021-05-31 13:26alostaleAssigned Toplatform => alostale
2021-05-31 13:30hgbotNote Added: 0128813
2021-06-04 10:51hgbotResolutionopen => fixed
2021-06-04 10:51hgbotStatusnew => closed
2021-06-04 10:51hgbotNote Added: 0129058
2021-06-04 10:51hgbotNote Added: 0129059
2021-06-04 11:47hgbotFixed in Version => PR21Q3
2021-06-04 11:47hgbotNote Added: 0129068
2022-11-18 09:23caristuRelationship addedrelated to 0049897

Notes
(0128813)
hgbot   
2021-05-31 13:30   
Merge Request created: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/25 [^]
(0129058)
hgbot   
2021-06-04 10:51   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/dbsm [^]
Changeset: 83897056d170385c18fe163b8d5465ccc3eae8c4
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 2021-06-04T10:47:42+02:00
URL: https://gitlab.com/openbravo/product/dbsm/-/commit/83897056d170385c18fe163b8d5465ccc3eae8c4 [^]

fixes BUG-46647: no default applied when inserting sample data

When inserting sample data neither default or on create default were
applied. This made more difficult to import sample data in an instance
with a different set of modules than the ones used to generate it.

Now when trying to import sample data with null values in mandatory columns
the following is applied:

 * If there is an on create default literal value it gets applied. Note on
   create default based on subqueries cannot be applied.
 * If there is no create default, default value gets applied.

---
A src-test/data/sampledata/NO_REQ1.xml
A src-test/data/sampledata/NO_REQ2.xml
A src-test/data/sampledata/NO_REQ3.xml
A src-test/data/sampledata/OPT_NULL.xml
A src-test/data/sampledata/SIMPLE.xml
A src-test/data/sampledata/UNKNOWN_COL.xml
A src-test/model/sampledata/SAMPLE_DATA_MODEL.xml
A src-test/src/org/openbravo/dbsm/test/sampledata/ImportSampleData.java
A src-test/src/org/openbravo/dbsm/test/sampledata/SampleDataSuite.java
M src-test/src/org/openbravo/dbsm/test/DBSMTestSuite.java
M src-test/src/org/openbravo/dbsm/test/base/DbsmTest.java
M src/org/apache/ddlutils/io/DataToDatabaseSink.java
M src/org/openbravo/ddlutils/task/ImportSampledata.java
---
(0129059)
hgbot   
2021-06-04 10:51   
Merge request merged: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/25 [^]
(0129068)
hgbot   
2021-06-04 11:47   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 870040145e6772c5c7a8a689055a6f6f2d53775a
Author: Asier Lostalé <asier.lostale@openbravo.com>
Date: 2021-06-04T10:55:51+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/870040145e6772c5c7a8a689055a6f6f2d53775a [^]

fixes BUG-46974: core2 tables export; fixes BUG-46647: sampledata defaults

dbsm including the fixes for:

BUG-46974: cannot export data of tables from core2

  Source data in core2 AD tables was not exported. ISSUE-46245 skips
  export of these tables in case the module that defines them is not
  installed.

  When exporting source data it was not working because it incorrectly
  dected core2 to be always not installed. It relied on
  DBSMOBUtil.allModules to be correctly completelly initialized which is
  not the case after calling getSortedTemplates.

  Now the optional modules not installed are initialized in getModules and
  kept after getSortedTemplates. belongsToOptionalUninstalledModule method
  must be invoked after getModules, now if called before it will
  explicitily fail.

BUG-46647: no default applied when inserting sample data

  When inserting sample data neither default or on create default were
  applied. This made more difficult to import sample data in an instance
  with a different set of modules than the ones used to generate it.

  Now when trying to import sample data with null values in mandatory columns
  the following is applied:

   * If there is an on create default literal value it gets applied. Note on
     create default based on subqueries cannot be applied.
   * If there is no create default, default value gets applied.

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