sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1729974 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql: EPSGDataAccess.java SQLTranslator.java
Date Fri, 12 Feb 2016 10:35:33 GMT
Author: desruisseaux
Date: Fri Feb 12 10:35:33 2016
New Revision: 1729974

URL: http://svn.apache.org/viewvc?rev=1729974&view=rev
Log:
Fix our use of boolean type on PostgreSQL.

Modified:
    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/SQLTranslator.java

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=1729974&r1=1729973&r2=1729974&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] Fri Feb 12 10:35:33 2016
@@ -778,8 +778,8 @@ addURIs:    for (int i=0; ; i++) {
      * @return The boolean at the specified column, or {@code null}.
      * @throws SQLException if an error occurred while querying the database.
      */
-    private static boolean getOptionalBoolean(final ResultSet result, final int columnIndex)
throws SQLException {
-        return result.getInt(columnIndex) != 0;
+    private boolean getOptionalBoolean(final ResultSet result, final int columnIndex) throws
SQLException {
+        return translator.useBoolean() ? result.getBoolean(columnIndex) : (result.getInt(columnIndex)
!= 0);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java?rev=1729974&r1=1729973&r2=1729974&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
[UTF-8] Fri Feb 12 10:35:33 2016
@@ -196,6 +196,8 @@ public class SQLTranslator implements Fu
     /**
      * {@code true} if the database uses the {@code BOOLEAN} type instead than {@code SMALLINT}
      * for the {@code show_crs}, {@code show_operation} and all {@code deprecated} fields.
+     *
+     * @see #useBoolean()
      */
     private boolean useBoolean;
 
@@ -297,7 +299,8 @@ public class SQLTranslator implements Fu
         try (ResultSet result = md.getColumns(catalog, schema, null, deprecated)) {
             while (result.next()) {
                 if (CharSequences.endsWith(result.getString("TABLE_NAME"), "Datum", true))
{
-                    useBoolean = result.getInt("DATA_TYPE") == Types.BOOLEAN;
+                    final int type = result.getInt("DATA_TYPE");
+                    useBoolean = (type == Types.BOOLEAN) || (type == Types.BIT);
                     break;
                 }
             }
@@ -344,6 +347,14 @@ public class SQLTranslator implements Fu
     }
 
     /**
+     * Returns {@code true} if the database uses the {@code BOOLEAN} type instead than {@code
SMALLINT}
+     * for the {@code show_crs}, {@code show_operation} and all {@code deprecated} fields.
+     */
+    final boolean useBoolean() {
+        return useBoolean;
+    }
+
+    /**
      * If the given string is empty, returns {@code null} instead.
      */
     private static String nonEmpty(final String s) {



Mime
View raw message