1. GeoTools
  2. GEOT-1835

EPSG factory needs to handle primary keys as integers


    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.4.4, 2.5-M2
    • Fix Version/s: 2.5.9
    • Component/s: referencing
    • Labels:
    • Environment:
      PostgreSQL 8.3


      The EPSG factory connected to a PostgreSQL 8.2 database works as expected. But connecting to the same database content on PostgreSQL 8.3 doesn't work anymore. We get the following exception:

      Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = character varying
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(
      	at org.geotools.referencing.factory.epsg.DirectEpsgFactory.createCoordinateReferenceSystem(
      HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

      This is because DirectEpsgFactory assigns a String parameter in a PreparedStatement for a column which is declared as integer in the database. Prior to PostgreSQL 8.3, the conversion was applied automatically. Starting with PostgreSQL 8.3, it is not anymore. From

      "Previously, if a non-character value was supplied to an operator or function that requires text input, it was automatically cast to text, for most (though not all) built-in data types. This no longer happens: an explicit cast to text is now required for all non-character-string types."

      The fix is to change the return value of the private toPrimaryKey(String) function from String to int and update the callers accordingly. In the main time, a workaround proposed by Mark Leslie is to redefine the integer -> text cast as implicit. See

        Issue Links


          Martin Desruisseaux added a comment -
          Fixed on geotidy.
          Martin Desruisseaux added a comment - Fixed on geotidy.


            • Assignee:
              Martin Desruisseaux


              • Created: