Changeset: 67d578e84e0b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=67d578e84e0b
Modified Files:
        java/ChangeLog.Jun2016
        java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
Branch: Jun2016
Log Message:

Implemented MonetDatabaseMetaData.supportsConvert() and
MonetDatabaseMetaData.supportsConvert(int fromType, int toType) methods.
It used to always return false. Now it returns true for the supported 
conversions.
This fixes Bug 3460.


diffs (179 lines):

diff --git a/java/ChangeLog.Jun2016 b/java/ChangeLog.Jun2016
--- a/java/ChangeLog.Jun2016
+++ b/java/ChangeLog.Jun2016
@@ -1,6 +1,12 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Thu May 19 2016 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- Implemented MonetDatabaseMetaData.supportsConvert() and
+  MonetDatabaseMetaData.supportsConvert(int fromType, int toType) methods.
+  It used to always return false. Now it returns true for the supported 
conversions.
+  This fixes Bug 3460.
+
 * Sun May  8 2016 Jennie Zhang <y.zh...@cwi.nl>
 - ResultSet.setFetchSize(): added a dummy implementation to get rid
   of the SQLFeatureNotSupportedException. In MonetDB, it does not
diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java 
b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -588,13 +588,158 @@ public class MonetDatabaseMetaData exten
                return true;
        }
 
+       /**
+        * Retrieves whether this database supports the JDBC scalar function
+        * CONVERT for the conversion of one JDBC type to another.
+        * The JDBC types are the generic SQL data types defined in 
java.sql.Types.
+        *
+        * @return true if so; false otherwise
+        */
        @Override
        public boolean supportsConvert() {
-               return false;
+               return true;
        }
 
+       /**
+        * Retrieves whether this database supports the JDBC scalar function
+        * CONVERT for conversions between the JDBC types fromType and toType.
+        * The JDBC types are the generic SQL data types defined in 
java.sql.Types.
+        *
+        * @return true if so; false otherwise
+        */
        @Override
        public boolean supportsConvert(int fromType, int toType) {
+               switch (fromType) {
+               case Types.BOOLEAN:
+                       switch (toType) {
+                       case Types.BOOLEAN:
+               /*      case Types.BIT: is not supported by MonetDB and will 
fail */
+                       case Types.TINYINT:
+                       case Types.SMALLINT:
+                       case Types.INTEGER:
+                       case Types.BIGINT:
+               /* conversion to FLOAT, REAL, DOUBLE, NUMERIC and DECIMAL is 
not supported by MonetDB */
+                       case Types.CHAR:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+       /*      case Types.BIT: is not supported by MonetDB and will fail */
+       /*      case Types.BINARY: is not supported by MonetDB and will fail */
+       /*      case Types.VARBINARY: is not supported by MonetDB and will fail 
*/
+       /*      case Types.LONGVARBINARY: is not supported by MonetDB and will 
fail */
+               case Types.BLOB:
+                       switch (toType) {
+               /*      case Types.BINARY: is not supported by MonetDB and will 
fail */
+               /*      case Types.VARBINARY: is not supported by MonetDB and 
will fail */
+               /*      case Types.LONGVARBINARY: is not supported by MonetDB 
and will fail */
+                       case Types.BLOB:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+               case Types.TINYINT:
+               case Types.SMALLINT:
+               case Types.INTEGER:
+               case Types.BIGINT:
+               case Types.FLOAT:
+               case Types.REAL:
+               case Types.DOUBLE:
+               case Types.NUMERIC:
+               case Types.DECIMAL:
+                       switch (toType) {
+                       case Types.BOOLEAN:
+               /*      case Types.BIT: is not supported by MonetDB and will 
fail */
+                       case Types.TINYINT:
+                       case Types.SMALLINT:
+                       case Types.INTEGER:
+                       case Types.BIGINT:
+                       case Types.FLOAT:
+                       case Types.REAL:
+                       case Types.DOUBLE:
+                       case Types.NUMERIC:
+                       case Types.DECIMAL:
+                       case Types.CHAR:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+               case Types.CHAR:
+               case Types.VARCHAR:
+       /*      case Types.LONGVARCHAR: is not supported by MonetDB and will 
fail */
+               case Types.CLOB:
+                       switch (toType) {
+                       case Types.BOOLEAN:
+               /*      case Types.BIT: is not supported by MonetDB and will 
fail */
+                       case Types.TINYINT:
+                       case Types.SMALLINT:
+                       case Types.INTEGER:
+                       case Types.BIGINT:
+                       case Types.FLOAT:
+                       case Types.REAL:
+                       case Types.DOUBLE:
+                       case Types.NUMERIC:
+                       case Types.DECIMAL:
+                       case Types.CHAR:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                       case Types.BLOB:
+                       case Types.DATE:
+                       case Types.TIME:
+                       case Types.TIMESTAMP:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+               case Types.DATE:
+                       switch (toType) {
+                       case Types.CHAR:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                       case Types.DATE:
+                       case Types.TIMESTAMP:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+               case Types.TIME:
+                       switch (toType) {
+                       case Types.CHAR:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                       case Types.TIME:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+               case Types.TIMESTAMP:
+                       switch (toType) {
+                       case Types.CHAR:
+                       case Types.VARCHAR:
+               /*      case Types.LONGVARCHAR: is not supported by MonetDB and 
will fail */
+                       case Types.CLOB:
+                       case Types.DATE:
+                       case Types.TIME:
+                       case Types.TIMESTAMP:
+                               return true;
+                       }
+                       // conversion to all other types is not supported
+                       return false;
+               }
+
+               // conversion from all other JDBC SQL types are not supported
                return false;
        }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to