You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2026/05/26 16:21:54 UTC

(sis) branch geoapi-4.0 updated (1f95591ce4 -> 5dd8cf8403)

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


    from 1f95591ce4 Remove unused `StoreUtilities` method and move URI-related method to `URIDataStoreProvider`.
     new 083fb59680 fix(sql): override sql datatype code for timestamp with timezone column
     new 5dd8cf8403 Merge branch 'fix/timestamp-tz-sql-type' into geoapi-4.0. https://github.com/apache/sis/pull/45

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/sis/storage/sql/feature/Column.java |  3 ++-
 .../apache/sis/storage/sql/feature/Database.java   | 21 ++++++++++++++++++++
 .../apache/sis/storage/sql/postgis/Postgres.java   | 23 ++++++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)


(sis) 02/02: Merge branch 'fix/timestamp-tz-sql-type' into geoapi-4.0. https://github.com/apache/sis/pull/45

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 5dd8cf8403c6e8e9de80ec9a7dc02dbd6777a0f2
Merge: 1f95591ce4 083fb59680
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue May 26 18:21:07 2026 +0200

    Merge branch 'fix/timestamp-tz-sql-type' into geoapi-4.0.
    https://github.com/apache/sis/pull/45

 .../org/apache/sis/storage/sql/feature/Column.java |  3 ++-
 .../apache/sis/storage/sql/feature/Database.java   | 21 ++++++++++++++++++++
 .../apache/sis/storage/sql/postgis/Postgres.java   | 23 ++++++++++++++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --cc endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java
index b475083191,6980238d97..02a9afc84c
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java
@@@ -47,6 -47,6 +47,7 @@@ import org.apache.sis.util.resources.Er
   *
   * @author  Alexis Manin (Geomatys)
   * @author  Martin Desruisseaux (Geomatys)
++ * @author  Guilhem Legal (Geomatys)
   *
   * @see ResultSet#getMetaData()
   * @see DatabaseMetaData#getColumns(String, String, String, String)
diff --cc endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
index f803411ac6,264c201505..609d97c2a0
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
@@@ -108,6 -108,6 +108,7 @@@ import org.opengis.filter.ValueReferenc
   * @author  Johann Sorel (Geomatys)
   * @author  Martin Desruisseaux (Geomatys)
   * @author  Alexis Manin (Geomatys)
++ * @author  Guilhem Legal (Geomatys)
   */
  public class Database<G> extends Syntax {
      /**
@@@ -767,7 -767,19 +768,27 @@@
      protected JDBCType getArrayComponentType(final Column columnDefinition) {
          return JDBCType.OTHER;
      }
 -    
 -    /**
 -     * Return the type of the column.
 -     * 
 -     * @param metadata the result of {@code DatabaseMetaData.getColumns(…)}.
 -     * @param typeName name of the sql type.
 -     * @return A java.sql.Types constant.
 -     * @throws SQLException 
 +
++    /**
++     * Returns the type of values in the column described by the given metadata.
++     * The {@code metadata} cursor is positioned on the row of the column for which to get the type,
++     * and the {@code metadata} columns are as defined in {@link DatabaseMetaData#getColumns(String,
++     * String, String, String)}. The value of the {@code "TYPE_NAME"} metadata column is given in
++     * argument for convenience.
++     *
++     * <p>The default implementation returns {@code metadata.getInt(Reflection.DATA_TYPE}.
++     * Some database drivers are known to return the wrong type, in which case this method
++     * is overridden for working around these bugs.</p>
++     *
++     * @param  metadata  the result of {@code DatabaseMetaData.getColumns(…)}.
++     * @param  typeName  the value of the {@code "TYPE_NAME"} metadata column.
++     * @return a {@link java.sql.Types} constant.
++     * @throws SQLException if an error occurred while fetching the type.
+      */
+     protected int getColumnDatatype(final ResultSet metadata, String typeName) throws SQLException {
+         return metadata.getInt(Reflection.DATA_TYPE);
+     }
+ 
      /**
       * Returns an identifier of the way binary data are encoded by the <abbr>JDBC</abbr> driver.
       * The default implementation returns {@link BinaryEncoding#RAW}.
diff --cc endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java
index 5c17f86caf,c456a8d407..29d79e1281
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java
@@@ -41,6 -41,6 +41,7 @@@ import org.apache.sis.storage.sql.featu
  import org.apache.sis.storage.sql.feature.SpatialSchema;
  import org.apache.sis.metadata.sql.internal.shared.Dialect;
  import org.apache.sis.storage.event.StoreListeners;
++import org.apache.sis.util.Workaround;
  import org.apache.sis.util.Version;
  
  
@@@ -53,6 -53,6 +54,7 @@@
   *
   * @author  Alexis Manin (Geomatys)
   * @author  Martin Desruisseaux (Geomatys)
++ * @author  Guilhem Legal (Geomatys)
   */
  public final class Postgres<G> extends Database<G> {
      /**
@@@ -149,6 -149,22 +151,27 @@@
          return super.getArrayComponentType(columnDefinition);
      }
  
+     /**
 -     * Return the type of the column.
 -     * 
 -     * @param metadata the result of {@code DatabaseMetaData.getColumns(…)}.
 -     * @param typeName name of the sql type.
 -     * @return A java.sql.Types constant.
 -     * @throws SQLException 
++     * Returns the type of the column with a workaround for {@code TIMESTAMP} with time zone.
++     * This is a workaround for a bug in PostgreSQL <abbr>JDBC</abbr> driver which returns
++     * {@link Types#TIMESTAMP} when it should return {@link Types#TIMESTAMP_WITH_TIMEZONE}.
++     *
++     * @param  metadata  the result of {@code DatabaseMetaData.getColumns(…)}.
++     * @param  typeName  the value of the {@code "TYPE_NAME"} metadata column.
++     * @return a {@link java.sql.Types} constant.
++     * @throws SQLException if an error occurred while fetching the type.
++     *
++     * @see <a href="https://github.com/pgjdbc/pgjdbc/pull/2715">PostgreSQL JDBC Driver issue #2715</a>
+      */
+     @Override
++    @Workaround(library = "pgjdbc", version = "42.7.7")
+     protected int getColumnDatatype(ResultSet metadata, String typeName) throws SQLException {
+         if ("timestamptz".equalsIgnoreCase(typeName)) {
+             return Types.TIMESTAMP_WITH_TIMEZONE;
+         }
+         return super.getColumnDatatype(metadata, typeName);
+     }
+ 
      /**
       * Returns the mapping for {@link Object} or unrecognized types.
       */


(sis) 01/02: fix(sql): override sql datatype code for timestamp with timezone column

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 083fb596809c6038091e4a28c552932adbd0cf49
Author: glegal <gu...@geomatys.com>
AuthorDate: Mon May 25 16:54:00 2026 +0200

    fix(sql): override sql datatype code for timestamp with timezone column
---
 .../main/org/apache/sis/storage/sql/feature/Column.java  |  2 +-
 .../org/apache/sis/storage/sql/feature/Database.java     | 12 ++++++++++++
 .../org/apache/sis/storage/sql/postgis/Postgres.java     | 16 ++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java
index b475083191..6980238d97 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Column.java
@@ -168,8 +168,8 @@ public class Column implements Cloneable {
      */
     Column(final Analyzer analyzer, final ResultSet metadata, final String quote) throws SQLException {
         label = name = analyzer.getUniqueString(metadata, Reflection.COLUMN_NAME);
-        type         = metadata.getInt(Reflection.DATA_TYPE);
         typeName     = localPart(metadata.getString(Reflection.TYPE_NAME), quote);
+        type         = analyzer.database.getColumnDatatype(metadata, typeName);
         precision    = metadata.getInt(Reflection.COLUMN_SIZE);
         isNullable   = Boolean.TRUE.equals(SQLUtilities.parseBoolean(metadata.getString(Reflection.IS_NULLABLE)));
         propertyName = label;
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
index f803411ac6..264c201505 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/Database.java
@@ -767,6 +767,18 @@ public class Database<G> extends Syntax {
     protected JDBCType getArrayComponentType(final Column columnDefinition) {
         return JDBCType.OTHER;
     }
+    
+    /**
+     * Return the type of the column.
+     * 
+     * @param metadata the result of {@code DatabaseMetaData.getColumns(…)}.
+     * @param typeName name of the sql type.
+     * @return A java.sql.Types constant.
+     * @throws SQLException 
+     */
+    protected int getColumnDatatype(final ResultSet metadata, String typeName) throws SQLException {
+        return metadata.getInt(Reflection.DATA_TYPE);
+    }
 
     /**
      * Returns an identifier of the way binary data are encoded by the <abbr>JDBC</abbr> driver.
diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java
index 5c17f86caf..c456a8d407 100644
--- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java
+++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/postgis/Postgres.java
@@ -149,6 +149,22 @@ public final class Postgres<G> extends Database<G> {
         return super.getArrayComponentType(columnDefinition);
     }
 
+    /**
+     * Return the type of the column.
+     * 
+     * @param metadata the result of {@code DatabaseMetaData.getColumns(…)}.
+     * @param typeName name of the sql type.
+     * @return A java.sql.Types constant.
+     * @throws SQLException 
+     */
+    @Override
+    protected int getColumnDatatype(ResultSet metadata, String typeName) throws SQLException {
+        if ("timestamptz".equalsIgnoreCase(typeName)) {
+            return Types.TIMESTAMP_WITH_TIMEZONE;
+        }
+        return super.getColumnDatatype(metadata, typeName);
+    }
+
     /**
      * Returns the mapping for {@link Object} or unrecognized types.
      */