You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2017/09/19 23:31:29 UTC
svn commit: r1808960 - in
/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx:
OColumn.java OColumnContainer.java descriptors/SdbcxColumnDescriptor.java
Author: damjan
Date: Tue Sep 19 23:31:29 2017
New Revision: 1808960
URL: http://svn.apache.org/viewvc?rev=1808960&view=rev
Log:
When an unknown column is passed to ColumnContainer, which it will be when
a new column is created, re-read it from the database.
Strings in UNO can't be null. Ensure this is the case in Column and
SdbcxColumnDescriptor.
Patch by: me
Modified:
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java?rev=1808960&r1=1808959&r2=1808960&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumn.java Tue Sep 19 23:31:29 2017
@@ -40,9 +40,9 @@ public class OColumn extends ODescriptor
"com.sun.star.sdbcx.Column"
};
- private String typeName;
- private String description;
- private String defaultValue;
+ private String typeName = "";
+ private String description = "";
+ private String defaultValue = "";
private int isNullable;
private int precision;
private int scale;
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java?rev=1808960&r1=1808959&r2=1808960&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java Tue Sep 19 23:31:29 2017
@@ -79,6 +79,23 @@ public class OColumnContainer extends OC
boolean isAutoIncrement = false;
boolean isCurrency = false;
int dataType = DataType.OTHER;
+
+ ColumnDescription columnDescription = columnDescriptions.get(name);
+ if (columnDescription == null) {
+ // could be a recently added column. Refresh:
+ List<ColumnDescription> newColumns = new SqlTableHelper().readColumns(metadata, table.catalogName, table.schemaName, table.getName());
+ for (ColumnDescription newColumnDescription : newColumns) {
+ if (newColumnDescription.columnName.equals(name)) {
+ columnDescriptions.put(name, newColumnDescription);
+ break;
+ }
+ }
+ columnDescription = columnDescriptions.get(name);
+ }
+ if (columnDescription == null) {
+ throw new SQLException("No column " + name + " found");
+ }
+
ExtraColumnInfo columnInfo = extraColumnInfo.get(name);
if (columnInfo == null) {
String composedName = DbTools.composeTableNameForSelect(metadata.getConnection(), table);
@@ -91,20 +108,15 @@ public class OColumnContainer extends OC
isCurrency = columnInfo.isCurrency;
dataType = columnInfo.dataType;
}
- ColumnDescription columnDescription = columnDescriptions.get(name);
- if (columnDescription != null) {
- XNameAccess primaryKeyColumns = DbTools.getPrimaryKeyColumns(UnoRuntime.queryInterface(XPropertySet.class, table));
- int nullable = columnDescription.nullable;
- if (nullable != ColumnValue.NO_NULLS && primaryKeyColumns != null && primaryKeyColumns.hasByName(name)) {
- nullable = ColumnValue.NO_NULLS;
- }
- return new OColumn(name, columnDescription.typeName, columnDescription.defaultValue, columnDescription.remarks,
- nullable, columnDescription.columnSize, columnDescription.decimalDigits, columnDescription.type,
- isAutoIncrement, false, isCurrency, isCaseSensitive());
- } else {
- // FIXME: do something like the C++ implementation does?
- throw new SQLException();
+
+ XNameAccess primaryKeyColumns = DbTools.getPrimaryKeyColumns(UnoRuntime.queryInterface(XPropertySet.class, table));
+ int nullable = columnDescription.nullable;
+ if (nullable != ColumnValue.NO_NULLS && primaryKeyColumns != null && primaryKeyColumns.hasByName(name)) {
+ nullable = ColumnValue.NO_NULLS;
}
+ return new OColumn(name, columnDescription.typeName, columnDescription.defaultValue, columnDescription.remarks,
+ nullable, columnDescription.columnSize, columnDescription.decimalDigits, columnDescription.type,
+ isAutoIncrement, false, isCurrency, isCaseSensitive());
}
@Override
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java?rev=1808960&r1=1808959&r2=1808960&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java Tue Sep 19 23:31:29 2017
@@ -34,14 +34,14 @@ public class SdbcxColumnDescriptor exten
};
protected int type;
- protected String typeName;
+ protected String typeName = "";
protected int precision;
protected int scale;
protected int isNullable;
protected boolean isAutoIncrement;
protected boolean isRowVersion;
- protected String description;
- protected String defaultValue;
+ protected String description = "";
+ protected String defaultValue = "";
protected boolean isCurrency;
public SdbcxColumnDescriptor(boolean isCaseSensitive) {