JDBCTextFeatureWriter corrupts data

Description

I'm filing this to the postgis component, but I believe it applies to any DataStore derived from JDBCDataStore that uses JDBCTextFeatureWriter.
If you use a code like this one:
FeatureWriter writer = fooDataStore().getFeatureWriter("fooTypeName",fooFilter,fooTransaction);
while( writer.hasNext() )
{
Feature feature = writer.next();
feature.setAttribute("fooAttrName",fooValue);
writer.write();
}
writer.close();

You'll end up having inside the "fooAttrName" attribute, not the fooValue, but the toString() of the AttributeType with name "fooAttrName".
This is because of line 379 from JDBCTextFeatureWriter.makeUpdateSql():
attrValue = addQuotes(attributes);
instead of:
attrValue = addQuotes(currAtt);

I'm also perplexed by the use of addQuotes(). It surely works with Postgis, because you can quote also numbers,
but I don't know about other RDBMS.

Bye
Paolo Rizzi

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:03 PM

CodeHaus Comment From: cholmes - Time: Tue, 12 Jul 2005 11:45:44 -0500
---------------------
Paolo - do you have commit rights? My svn isn't working right now, so I can't put this fix in.

As for addQuotes() - it seems like it should be defined as an abstract method, or at the very least do nothing, and then subclasses should put the appropriate quotes on if needed.

codehaus
April 10, 2015, 3:03 PM

CodeHaus Comment From: caipirginka - Time: Tue, 12 Jul 2005 11:56:19 -0500
---------------------
I don't have commit rights. My workmate Luca Percich has them, but for the MIFDataStore module, so it may not be appropriate...

Anyway he went home already, but if you say it's ok, I can ask him to commit the fix tomorrow.

As for addQuotes() I too think that it should be left to subclasses.

But before modifying it, we should check and maybe modify each DataStore derived from JDBCDataStore,

because they may already be relying on it doing it's job.

codehaus
April 10, 2015, 3:03 PM

CodeHaus Comment From: groldan - Time: Tue, 2 Aug 2005 07:23:46 -0500
---------------------
this issue is already fixed as <a href="https://jira.codehaus.org/browse/GEOT-646" title="JDBCTextFeatureWriter encodes the AttributeType instead of its value" class="issue-link" data-issue-key="GEOT-646"><strike>GEOT-646</strike></a>

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Affects versions

Priority

High
Configure