EPSG factory needs to handle primary keys as integers
-----------------------------------------------------
Key: GEOT-1835
URL: http://jira.codehaus.org/browse/GEOT-1835
Project: GeoTools
Issue Type: Bug
Components: core referencing
Affects Versions: 2.5-M2, 2.4.4
Environment: PostgreSQL 8.3
Reporter: Martin Desruisseaux
Assignee: Martin Desruisseaux
Fix For: 2.5.0
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:
{noformat}
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist:
integer = character varying
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
at
org.geotools.referencing.factory.epsg.DirectEpsgFactory.createCoordinateReferenceSystem(DirectEpsgFactory.java:1847)
HINT: No operator matches the given name and argument type(s). You might need
to add explicit type casts.
{noformat}
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
http://www.postgresql.org/docs/8.3/static/release-8-3.html:
{quote}
"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."
{quote}
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
http://www.postgresql.org/docs/8.3/interactive/sql-createcast.html.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel