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 <[email protected]>
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.
       */

Reply via email to