diff options
author | Chris Khoun | 2012-08-20 19:52:54 -0400 |
---|---|---|
committer | Brian Payton | 2012-08-20 19:52:54 -0400 |
commit | 43b09979b605b875c89792aef7a7deb152dc5928 (patch) | |
tree | 981fa517ddd2a8a909fb19b8b91b42b74104ee54 | |
parent | 3bbd0b3abab85f45def450d58ceb2bfd6de8232f (diff) | |
download | org.eclipse.datatools.sqltools-43b09979b605b875c89792aef7a7deb152dc5928.zip org.eclipse.datatools.sqltools-43b09979b605b875c89792aef7a7deb152dc5928.tar.gz org.eclipse.datatools.sqltools-43b09979b605b875c89792aef7a7deb152dc5928.tar.xz |
[386944] Applied patch to o.e.d.sqltools.data.corev201208201700
-rw-r--r-- | plugins/org.eclipse.datatools.sqltools.data.core/src/org/eclipse/datatools/sqltools/data/internal/core/editor/RowDataImpl.java | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/plugins/org.eclipse.datatools.sqltools.data.core/src/org/eclipse/datatools/sqltools/data/internal/core/editor/RowDataImpl.java b/plugins/org.eclipse.datatools.sqltools.data.core/src/org/eclipse/datatools/sqltools/data/internal/core/editor/RowDataImpl.java index 8a000d5..7a134fe 100644 --- a/plugins/org.eclipse.datatools.sqltools.data.core/src/org/eclipse/datatools/sqltools/data/internal/core/editor/RowDataImpl.java +++ b/plugins/org.eclipse.datatools.sqltools.data.core/src/org/eclipse/datatools/sqltools/data/internal/core/editor/RowDataImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -87,8 +87,8 @@ public class RowDataImpl extends AbstractRowData int index = -1; for (int i=0; i<table.getColumnCount(); ++i) { Column sqlCol = (Column) table.getResultColumns().get(i); - //Do not include columns that are always generated - if (sqlCol.getIdentitySpecifier() == null) { + //Omit the always generated columns and columns where default value needs to be used. + if ( isColumnIncluded(sqlCol, i) ) { index++; if (exprs.elementAt(index)!=null) { cols.add(table.getQuotedColumnName(i)); @@ -180,7 +180,8 @@ public class RowDataImpl extends AbstractRowData Vector exprs = new Vector(); for (int col=0; col<newData.length; ++col) { Column sqlCol = (Column) table.getResultColumns().get(col); - if (sqlCol.getIdentitySpecifier() == null) { + //Omit the always generated columns and columns where default value needs to be used. + if ( isColumnIncluded(sqlCol, col) ) { exprs.add( table.getColumnDataAccessor(col).getValuesExpr(newData[col]) ); } } @@ -191,8 +192,8 @@ public class RowDataImpl extends AbstractRowData { for (int col=0; col<newData.length; ++col) { Column sqlCol = (Column) table.getResultColumns().get(col); - //Omit the always generted columns - if (sqlCol.getIdentitySpecifier() == null) { + //Omit the always generated columns and columns where default value needs to be used. + if ( isColumnIncluded(sqlCol, col) ) { String[] args = table.getColumnDataAccessor(col).writeValuesExprArgs(pst, stmtLog.getArgsCount(), newData[col], table.getColumnType(col)); @@ -274,7 +275,34 @@ public class RowDataImpl extends AbstractRowData return sb.toString(); } + protected boolean isColumnIncluded(Column sqlCol, int colIndex) + { + if ( sqlCol.getIdentitySpecifier() == null // + && sqlCol.getGenerateExpression() == null // + && !this.useDefaultValue(sqlCol, colIndex) ) + { + return true; + } + + return false; + } + protected boolean useDefaultValue(Column sqlCol, int colIndex) + { + if (this.getValue(colIndex) != null //user has given some value in UI, no default value here. + || sqlCol.getDefaultValue() == null || + sqlCol.getDefaultValue().trim().equalsIgnoreCase("NULL")) //there is no default value for column + return false; + if (sqlCol.getDefaultValue() != null) { + if (this.state == STATE_ORIGINAL) + return true ; //no UI mods + if (this.state == STATE_UPDATED) + return this.newData[colIndex] == null ? false : true; + if (this.state == STATE_INSERTED) //row to be inserted, but user has not given any values for column with default + return this.newData[colIndex] == null ? true : false; + } + return false ; //no default value and no value in UI either + } } |