[Geoserver-users] WFS GetFeature request with fid filter fails with Geoserver 1.6.4 and Postgis Datastore With a Entity configured on a View

Hello i have some problem with a entity configured on a postgis
datastore with a view instead on a table when i send a WFS GetFeature
request with a fid filter. I obtain a similar error with Geoserver
1.5.4 and 1.6.4 Similar request works fine when the entity type
correspond to a table on the database.

my request :

<?xml version='1.0' encoding='utf-8' ?>
<wfs:GetFeature xmlns:gml="http://www.opengis.net/gml&quot;
outputFormat="GML2" service="WFS"
xmlns:ogc="http://www.opengis.net/ogc&quot; maxFeatures="1" xmlns=""
xmlns:wfs="http://www.opengis.net/wfs&quot; version="1.0.0"> <wfs:Query
typeName="gisnet3:geonote_point" xmlns:gisnet3="http://gisnet3">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc&quot;&gt;
<ogc:FeatureId fid="geonote_point.nfm--49e4e129_11b0c9f16f7_-7f5b"></ogc:FeatureId>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

the exception returned by geoserver

<ServiceExceptionReport version="1.2.0"
xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd&quot;&gt;
<ServiceException>
error:Translator error
Translator error
Error reading Features
Could not aquire feature:org.geotools.data.DataSourceException: Error
Performing SQL query: SELECT "id", "title", "decription", "type",
"links", "image_links", "video_links",
encode(asBinary(force_2d("the_point"),'XDR'),'base64') FROM
"public"."geonote_point" WHERE () LIMIT 1
Error Performing SQL query: SELECT "id", "title", "decription",
"type", "links", "image_links", "video_links",
encode(asBinary(force_2d("the_point"),'XDR'),'base64') FROM
"public"."geonote_point" WHERE () LIMIT 1
ERREUR: erreur de syntaxe sur ou près de « ) »
</ServiceException>
</ServiceExceptionReport>

I obtain the same error with a table without primary key or with a
composed primary key

Nicolas CASTEL ha scritto:

Hello i have some problem with a entity configured on a postgis
datastore with a view instead on a table when i send a WFS GetFeature
request with a fid filter. I obtain a similar error with Geoserver
1.5.4 and 1.6.4 Similar request works fine when the entity type
correspond to a table on the database.

my request :

<?xml version='1.0' encoding='utf-8' ?>
<wfs:GetFeature xmlns:gml="http://www.opengis.net/gml&quot;
outputFormat="GML2" service="WFS"
xmlns:ogc="http://www.opengis.net/ogc&quot; maxFeatures="1" xmlns=""
xmlns:wfs="http://www.opengis.net/wfs&quot; version="1.0.0"> <wfs:Query
typeName="gisnet3:geonote_point" xmlns:gisnet3="http://gisnet3">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc&quot;&gt;
<ogc:FeatureId fid="geonote_point.nfm--49e4e129_11b0c9f16f7_-7f5b"></ogc:FeatureId>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

the exception returned by geoserver

<ServiceExceptionReport version="1.2.0"
xsi:schemaLocation="http://www.opengis.net/ogc
http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd&quot;&gt;
<ServiceException>
error:Translator error
Translator error
Error reading Features
Could not aquire feature:org.geotools.data.DataSourceException: Error
Performing SQL query: SELECT "id", "title", "decription", "type",
"links", "image_links", "video_links",
encode(asBinary(force_2d("the_point"),'XDR'),'base64') FROM
"public"."geonote_point" WHERE () LIMIT 1
Error Performing SQL query: SELECT "id", "title", "decription",
"type", "links", "image_links", "video_links",
encode(asBinary(force_2d("the_point"),'XDR'),'base64') FROM
"public"."geonote_point" WHERE () LIMIT 1
ERREUR: erreur de syntaxe sur ou près de « ) »
</ServiceException>
</ServiceExceptionReport>

I obtain the same error with a table without primary key or with a
composed primary key

This is similar to Janne Nivala problem ("Invalid SQL query with Oracle Spatial view"). In the first case, the FID is made up, and it cannot
be encoded back into a SQL.

The second case is different, the FID you are using does not conform
to the proper structure and thus cannot be parsed back, resulting
in the same error. In the case of multicolumn tables the structure
or a fid is:
typeName.att1&att2&att3&...
where each attX is the attribute value, URLEncoded to make sure no
invalid character slips into it (feature id values have a quite strict
set of valid characters).

So for example, if your table is "people" and you have two columns
name and surname that make up the primary key the result would be:
people.nicolas&castel
but if the person is André Artoi the fid will become:
people.Andr%E9&Artois

Anyways, the error you're getting should not be there, when FID
is invalid you should just get an empty feature collection back:
http://jira.codehaus.org/browse/GEOS-2039

Hope this helps
Cheers
Andrea