Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 386944 - Incorrect insert SQL generated on rows of tables with columns defined as "NOT NULL WITH DEFAULT"
Summary: Incorrect insert SQL generated on rows of tables with columns defined as "NOT...
Status: RESOLVED FIXED
Alias: None
Product: Data Tools
Classification: Tools
Component: SQL Query Builder (show other bugs)
Version: 1.8.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.10.1   Edit
Assignee: Brian Payton CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-09 11:50 EDT by Chris Khoun CLA
Modified: 2013-05-29 18:26 EDT (History)
2 users (show)

See Also:


Attachments
Code fix for this problem on top of DTP 1.8.2 (23.65 KB, text/plain)
2012-08-09 11:50 EDT, Chris Khoun CLA
no flags Details
Code fix for this problem on top of DTP 1.8.2 (UPDATED PATCH) (3.73 KB, patch)
2012-08-14 14:30 EDT, Chris Khoun CLA
bpayton: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Khoun CLA 2012-08-09 11:50:06 EDT
Created attachment 219717 [details]
Code fix for this problem on top of DTP 1.8.2

I checked the master branch of DTP to make sure this bug wasn't already fixed in the latest code base. I have attached a patch that fixes this issue. The patch is based on DTP 1.8.2.

Repro Steps.
1. Open any product that utilizes DTP 1.8.2 such as RAD 8.5.
2. Open the Data perspective and connect to a DB2 database through the Data Source Explorer. (I used a local DB2 LUW v10.1 but any os/version should reproduce this)
3. Select "New SQL Script" and create a new table with the following query.

CREATE TABLE DB2ADMIN.TESTTABLE1 (NAME1  VARCHAR(20) NOT NULL,
				  NAME2  VARCHAR(20) NOT NULL WITH DEFAULT,
				  NUM1   INTEGER NOT NULL WITH DEFAULT)

3. Expand the database tree in the Data Source Explorer to your newly created table.
4. Right click the table -> Data -> Edit
5. Enter a value into the NAME1 column (don't put anything in the other columns)
6. Right click -> Save   this will trigger the error.

The generated insert is as follows (which is wrong)
insert into "DB2ADMIN"."TESTTABLE1" ("NAME1", "NAME2", "NUM1") values('CKTEST1', null, null)
It should instead actually be
insert into "DB2ADMIN"."TESTTABLE1" ("NAME1") values('CKTEST1')
Comment 1 Brian Payton CLA 2012-08-14 14:14:18 EDT
Please re-do your patch file so that it includes only the proposed source changes.  The current patch references all the modified .class files as well.
Comment 2 Chris Khoun CLA 2012-08-14 14:30:43 EDT
Created attachment 219879 [details]
Code fix for this problem on top of DTP 1.8.2 (UPDATED PATCH)
Comment 3 Brian Payton CLA 2012-08-20 20:11:09 EDT
I've delivered the changes to the 1.10.1 (head) stream as well the 1.8.2a stream.

ere's the Git commit record for the 1.10.1 stream:
http://git.eclipse.org/c/datatools/org.eclipse.datatools.sqltools.git/commit/?id=47f2cde6f116222636d1712cd28a98cb6f618425

And here's the commit record for the 1.8.2a branch stream:
http://git.eclipse.org/c/datatools/org.eclipse.datatools.sqltools.git/commit/?h=DTP_1_8_2_Branch_a&id=43b09979b605b875c89792aef7a7deb152dc5928