sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1750347 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql: AuthorityCodes.java EPSGDataAccess.java EPSGInstaller.java TableInfo.java
Date Mon, 27 Jun 2016 14:30:19 GMT
Author: desruisseaux
Date: Mon Jun 27 14:30:18 2016
New Revision: 1750347

URL: http://svn.apache.org/viewvc?rev=1750347&view=rev
Log:
Bug fix: enum types need to be casted to VARCHAR on PostgreSQL.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java?rev=1750347&r1=1750346&r2=1750347&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
[UTF-8] Mon Jun 27 14:30:18 2016
@@ -148,8 +148,8 @@ final class AuthorityCodes extends Abstr
             for (int i=0; i<table.subTypes.length; i++) {
                 final Class<?> candidate = table.subTypes[i];
                 if (candidate.isAssignableFrom(type)) {
-                    buffer.append(" WHERE (").append(table.typeColumn)
-                          .append(" LIKE '").append(table.typeNames[i]).append("%')");
+                    buffer.append(" WHERE (CAST(").append(table.typeColumn).append(" AS ").append(TableInfo.ENUM_REPLACEMENT)
+                          .append(") LIKE '").append(table.typeNames[i]).append("%')");
                     hasWhere = true;
                     tableType = candidate;
                     break;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1750347&r1=1750346&r2=1750347&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] Mon Jun 27 14:30:18 2016
@@ -3216,7 +3216,7 @@ next:               while (r.next()) {
                     "SELECT COORD_REF_SYS_CODE" +
                     " FROM [Coordinate Reference System]" +
                     " WHERE PROJECTION_CONV_CODE = ?" +
-                      " AND COORD_REF_SYS_KIND LIKE 'projected%'", code))
+                      " AND CAST(COORD_REF_SYS_KIND AS " + TableInfo.ENUM_REPLACEMENT + ")
LIKE 'projected%'", code))
             {
                 projection = result.next();
             }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1750347&r1=1750346&r2=1750347&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
[UTF-8] Mon Jun 27 14:30:18 2016
@@ -159,9 +159,9 @@ final class EPSGInstaller extends Script
             prependNamespace(schema);
         }
         if (!isEnumTypeSupported) {
-            addReplacement(SQLTranslator.TABLE_PREFIX + "datum_kind", "VARCHAR(24)");
-            addReplacement(SQLTranslator.TABLE_PREFIX + "crs_kind",   "VARCHAR(24)");
-            addReplacement(SQLTranslator.TABLE_PREFIX + "cs_kind",    "VARCHAR(24)");
+            addReplacement(SQLTranslator.TABLE_PREFIX + "datum_kind", TableInfo.ENUM_REPLACEMENT);
+            addReplacement(SQLTranslator.TABLE_PREFIX + "crs_kind",   TableInfo.ENUM_REPLACEMENT);
+            addReplacement(SQLTranslator.TABLE_PREFIX + "cs_kind",    TableInfo.ENUM_REPLACEMENT);
             addReplacement(SQLTranslator.TABLE_PREFIX + "table_name", "VARCHAR(80)");
         }
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java?rev=1750347&r1=1750346&r2=1750347&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
[UTF-8] Mon Jun 27 14:30:18 2016
@@ -162,10 +162,17 @@ final class TableInfo {
 
     /**
      * Column type for the type (usually with the {@code "_TYPE"} suffix), or {@code null}.
+     * {@link EPSGDataAccess} and {@link AuthorityCodes} assumes that values in this column
+     * have the maximal length described in the {@value #ENUM_REPLACEMENT} statement.
      */
     final String typeColumn;
 
     /**
+     * The SQL type to use as a replacement for enumerated values on databases that do not
support enumerations.
+     */
+    static final String ENUM_REPLACEMENT = "VARCHAR(24)";
+
+    /**
      * Sub-interfaces of {@link #type} to handle, or {@code null} if none.
      */
     final Class<?>[] subTypes;



Mime
View raw message