Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033964Openbravo ERPA. Platformpublic2016-09-13 12:352016-09-29 09:02
gorkaion 
caristu 
normalmajoralways
closedfixed 
5
pi 
3.0PR16Q4 
alostale
Core
No
0033964: Default value is not dropped when column definition changes
If a database column definition changes removing the default value the udpate.database task is not dropping the default value in the database.
1 Create a date column not null with sysdate as default value and on create default value.
2 Check that it is properly created in the database.
3 Modify the xml definition to set is as required false and remove the default and onCreateDefault values.
4 Update the database and check that the required and onCreateDefault values are properly updated but the default value is still "now()".
5 Modify the xml definition and set the default value to null.
6 Update the database again and check that the default value is still "now()"
No tags attached.
diff issue33964.diff (6,574) 2016-09-15 10:10
https://issues.openbravo.com/file_download.php?file_id=9819&type=bug
Issue History
2016-09-13 12:35gorkaionNew Issue
2016-09-13 12:35gorkaionAssigned To => caristu
2016-09-13 12:35gorkaionModules => Core
2016-09-13 12:35gorkaionTriggers an Emergency Pack => No
2016-09-13 12:37gorkaionSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=13099#r13099
2016-09-13 15:45caristuNote Added: 0089921
2016-09-13 15:45caristuStatusnew => acknowledged
2016-09-13 15:45caristuStatusacknowledged => scheduled
2016-09-15 10:10caristuFile Added: issue33964.diff
2016-09-15 10:11caristuNote Added: 0089970
2016-09-15 10:11caristuNote View State: public: 89970
2016-09-26 16:53hgbotCheckin
2016-09-26 16:53hgbotNote Added: 0090271
2016-09-26 16:57hgbotCheckin
2016-09-26 16:57hgbotNote Added: 0090272
2016-09-26 17:01hgbotCheckin
2016-09-26 17:01hgbotNote Added: 0090273
2016-09-26 17:01hgbotStatusscheduled => resolved
2016-09-26 17:01hgbotResolutionopen => fixed
2016-09-26 17:01hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/fb801d35d71193ac5a7448ed8346b0d376afa311 [^]
2016-09-26 17:02caristuReview Assigned To => alostale
2016-09-26 17:03caristuIssue Monitored: alostale
2016-09-26 22:05hudsonbotCheckin
2016-09-26 22:05hudsonbotNote Added: 0090277
2016-09-28 19:00hgbotCheckin
2016-09-28 19:00hgbotNote Added: 0090355
2016-09-28 19:03hgbotCheckin
2016-09-28 19:03hgbotNote Added: 0090356
2016-09-29 00:02hudsonbotCheckin
2016-09-29 00:02hudsonbotNote Added: 0090365
2016-09-29 09:02alostaleNote Added: 0090368
2016-09-29 09:02alostaleStatusresolved => closed
2016-09-29 09:02alostaleFixed in Version => 3.0PR16Q4

Notes
(0089921)
caristu   
2016-09-13 15:45   
The problem is on the ModelComparator class.

When comparing the source default value and the target default value, it parses both values expecting that they are fixed values.

When the default value is a function like now(), the default value should not be parsed before comparing it.
(0089970)
caristu   
2016-09-15 10:11   
Attached issue with the proposed solution + test case
(0090271)
hgbot   
2016-09-26 16:53   
Repository: erp/devel/dbsm-main
Changeset: 88837e2a0158e88052615a17326efe44d036caeb
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Mon Sep 26 16:52:29 2016 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/88837e2a0158e88052615a17326efe44d036caeb [^]

related to issue 33964: Default value not dropped if column definition changes

The problem was caused because when the default value was a function (NOW()) this value was being parsed returning a null value. This was making impossible to detect the change in the default value by DB Source Manager. Now if the default value is function the value is not parsed.

Together with this, now when the default value is changed to NULL for a character varying column in Postgres the NULL value is translated properly within the PostgreSqlModelLoader.

---
M src/org/apache/ddlutils/model/ValueObject.java
M src/org/apache/ddlutils/platform/ModelLoaderBase.java
M src/org/apache/ddlutils/platform/postgresql/PostgreSqlModelLoader.java
A src-test/model/defaults/BASE_MODEL.xml
A src-test/model/defaults/BASE_MODEL2.xml
A src-test/model/defaults/BASE_MODEL2_WITH_DEFAULT.xml
A src-test/model/defaults/BASE_MODEL_WITH_DEFAULT.xml
A src-test/src/org/openbravo/dbsm/test/model/data/DefaultValuesTest.java
---
(0090272)
hgbot   
2016-09-26 16:57   
Repository: erp/devel/dbsm-main
Changeset: 6bb0a381189b2a2a99c6a1222aea495191d9eb38
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Mon Sep 26 16:57:01 2016 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/6bb0a381189b2a2a99c6a1222aea495191d9eb38 [^]

related to issue 33964: include new test cases for defaults into the test suite

---
M src-test/src/org/openbravo/dbsm/test/model/ModelSuite.java
---
(0090273)
hgbot   
2016-09-26 17:01   
Repository: erp/devel/pi
Changeset: fb801d35d71193ac5a7448ed8346b0d376afa311
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Mon Sep 26 17:00:54 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/fb801d35d71193ac5a7448ed8346b0d376afa311 [^]

fixes issue 33964: Default value not dropped if column definition changes

---
M src-db/database/lib/dbsourcemanager.jar
---
(0090277)
hudsonbot   
2016-09-26 22:05   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/d32e95b900dd [^]
Maturity status: Test
(0090355)
hgbot   
2016-09-28 19:00   
Repository: erp/devel/dbsm-main
Changeset: 19aa8c3018b71ce47bf9550a6baae32f799cae80
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 28 18:51:42 2016 +0200
URL: http://code.openbravo.com/erp/devel/dbsm-main/rev/19aa8c3018b71ce47bf9550a6baae32f799cae80 [^]

related to issue 33964: use DROP DEFAULT when the column default is removed

---
M src/org/apache/ddlutils/platform/postgresql/PostgreSqlBuilder.java
M src/org/apache/ddlutils/platform/postgresql/PostgreSqlModelLoader.java
---
(0090356)
hgbot   
2016-09-28 19:03   
Repository: erp/devel/pi
Changeset: cfcdef1f8efe7ba22f3e98a29eaaf93d5805f05a
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 28 19:02:56 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/cfcdef1f8efe7ba22f3e98a29eaaf93d5805f05a [^]

related to issue 33964: update DB Source Manager with code review improvements

---
M src-db/database/lib/dbsourcemanager.jar
---
(0090365)
hudsonbot   
2016-09-29 00:02   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/2cd54ee6264a [^]
Maturity status: Test
(0090368)
alostale   
2016-09-29 09:02   
Code reviewed + tested