This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit ab0610bcf710a63b86244ab7d9142b8b14cf0785 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Fri Apr 11 12:22:35 2025 +0200 Remove the hack for DuckDB 1.2.1 since it has been fixed in DuckDB 1.2.2.0. Document DuckDB 1.2.2.0 as the minimal version required by Apache SIS. --- .../org/apache/sis/metadata/sql/privy/Dialect.java | 33 +++------------------- .../org/apache/sis/storage/sql/duckdb/DuckDB.java | 2 +- .../sis/storage/sql/duckdb/package-info.java | 4 +++ .../storage/sql/feature/SelectionClauseWriter.java | 4 +-- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java index c5b4709a9f..83af6d9816 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/sql/privy/Dialect.java @@ -19,7 +19,6 @@ package org.apache.sis.metadata.sql.privy; import java.sql.SQLException; import java.sql.DatabaseMetaData; import org.apache.sis.util.CharSequences; -import org.apache.sis.util.Workaround; import org.apache.sis.util.privy.Constants; @@ -113,19 +112,11 @@ public enum Dialect { * LOAD spatial * } * - * @see <a href="https://github.com/duckdb/duckdb-java/issues/165">DuckDB-Java issue #165</a> + * <h4>Requirements</h4> + * Apache SIS requires DuckDB 1.2.2.0 or later. This is needed for the correction of + * <a href="https://github.com/duckdb/duckdb-java/issues/165">DuckDB-Java issue #165</a>. */ - DUCKDB("duckdb", 0) { - @Override - @Workaround(library = "DuckDB", version = "1.2.1") - public String toCompatibleMetadataPattern(String pattern, final int argument) { - switch (argument) { - case 1: if (pattern == null) pattern = "%"; break; - case 2: pattern = pattern.replace("\\", ""); break; - } - return pattern; - } - }; + DUCKDB("duckdb", 0); /** * The protocol in JDBC URL, or {@code null} if unknown. @@ -217,22 +208,6 @@ public enum Dialect { return (flags & Supports.SRID) != 0; } - /** - * Converts the pattern to something that can be used for requesting metadata. - * This is a workaround for a DuckDB bug and may be removed in a future version. - * - * @param pattern the schema pattern to apply. - * @param argument 1 for the {@code schemaPattern}, 2 for {@code functionNamePattern}. - * @return the schema pattern to use. - * - * @see DatabaseMetaData#getFunctions(String, String, String) - * @see <a href="https://github.com/duckdb/duckdb-java/issues/165">DuckDB-Java issue #165</a> - */ - @Workaround(library = "DuckDB", version = "1.2.1") - public String toCompatibleMetadataPattern(String pattern, int argument) { - return pattern; - } - /** * Returns the presumed SQL dialect. * If this method cannot guess the dialect, than {@link #ANSI} is presumed. diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/DuckDB.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/DuckDB.java index 58f6ada7da..b20ca19d84 100644 --- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/DuckDB.java +++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/DuckDB.java @@ -33,7 +33,7 @@ import org.apache.sis.storage.sql.feature.SelectionClauseWriter; /** * Information about a connection to a DuckDB database. * This class specializes some of the functions for converting DuckDB spatial extension objects to Java objects. - * See the package Javadoc for recommendation about how to connect to a DuckDB database. + * See the package Javadoc for version requirement and recommendation about how to connect to a DuckDB database. * * @param <G> the type of geometry objects. Depends on the backing implementation (ESRI, JTS, Java2D…). * diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/package-info.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/package-info.java index 5c100e6246..f0a5f7125f 100644 --- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/package-info.java +++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/duckdb/package-info.java @@ -54,6 +54,10 @@ * } * } * + * <h2>Requirements</h2> + * Apache SIS requires DuckDB 1.2.2.0 or later. This is needed for the correction of + * <a href="https://github.com/duckdb/duckdb-java/issues/165">DuckDB-Java issue #165</a>. + * * @author Guilhem Legal (Geomatys) * @author Martin Desruisseaux (Geomatys) */ diff --git a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java index a9e96dd22c..5468a84c63 100644 --- a/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java +++ b/endorsed/src/org.apache.sis.storage.sql/main/org/apache/sis/storage/sql/feature/SelectionClauseWriter.java @@ -174,8 +174,8 @@ public class SelectionClauseWriter extends Visitor<Feature, SelectionClause> { */ final String prefix = database.escapeWildcards(lowerCase ? "st_" : "ST_"); try (ResultSet r = metadata.getFunctions(database.catalogOfSpatialTables, - database.dialect.toCompatibleMetadataPattern(database.schemaOfSpatialTables, 1), - database.dialect.toCompatibleMetadataPattern(prefix + '%', 2))) + database.schemaOfSpatialTables, + prefix + '%')) { while (r.next()) { unsupported.remove(r.getString("FUNCTION_NAME"));