sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1791953 - /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
Date Wed, 19 Apr 2017 19:01:13 GMT
Author: desruisseaux
Date: Wed Apr 19 19:01:13 2017
New Revision: 1791953

URL: http://svn.apache.org/viewvc?rev=1791953&view=rev
Log:
Bug fix when the EPSG tables are both defined in an "epsg" schema and with the "epsg_" prefix
in table names.

Modified:
    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/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=1791953&r1=1791952&r2=1791953&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] Wed Apr 19 19:01:13 2017
@@ -101,7 +101,7 @@ import java.util.function.Function;
  * @author  Martin Desruisseaux (IRD)
  * @author  Didier Richard (IGN)
  * @author  John Grange
- * @version 0.7
+ * @version 0.8
  * @since   0.7
  * @module
  */
@@ -161,14 +161,21 @@ public class SQLTranslator implements Fu
      *       In such case, {@code SQLTranslator} will tries to automatically detect the schema.</li>
      * </ul>
      *
-     * <p><b>Consider this field as final.</b> This field is non-final
only for construction convenience,
-     * or for updating after the {@link EPSGInstaller} class created the database.</p>
+     * <b>Consider this field as final.</b> This field is non-final only for
construction convenience,
+     * or for updating after the {@link EPSGInstaller} class created the database.
      *
      * @see #getSchema()
      */
     private String schema;
 
     /**
+     * Whether the table names are prefixed by {@value #TABLE_PREFIX}. When installed by
Apache SIS,
+     * the table names are not prefixed if the tables are stored in a schema. However the
dataset may
+     * have been installed manually by users following different rules.
+     */
+    private boolean isPrefixed;
+
+    /**
      * Mapping from words used in the MS-Access database to words used in the ANSI versions
of EPSG databases.
      * A word may be a table or a column name, or a part of it. A table name may consist
in many words separated
      * by spaces.
@@ -256,6 +263,7 @@ public class SQLTranslator implements Fu
             try (ResultSet result = md.getTables(catalog, schema, table, null)) {
                 if (result.next()) {
                     isTableFound    = true;
+                    isPrefixed      = table.startsWith(TABLE_PREFIX);
                     quoteTableNames = (i == MIXED_CASE);
                     do {
                         catalog = result.getString("TABLE_CAT");
@@ -406,7 +414,7 @@ public class SQLTranslator implements Fu
                 if (quoteTableNames) {
                     ansi.append(quote);
                 }
-                if (schema == null) {
+                if (isPrefixed) {
                     ansi.append(TABLE_PREFIX);
                 }
                 if (quoteTableNames) {



Mime
View raw message