hmmmm - So I did some more digging...
Looking here: http://blog.geoserver.org/2018/03/20/geoserver-2-13-0-released/ the HStore column is meant to come back as a JSON formatted map from geoserver ( which makes sense ), so my fix cannot be applied permanently. I think one of 2 things is going on: 1) Am I missing a plugin that extends the SQL dialect that provides an HStore converter? 2) if # 1 is not it, I think the current SQL Dialect should be modified such that HStore attributes are encoded using correct PostgreSQL syntax. On Thu, Oct 14, 2021 at 10:28 PM Alessandro Ferrucci < alessandroferru...@gmail.com> wrote: > OK - I ended up implementing a new HStore class in my own project that > overrides org.geotools.data.postgis.HStore and I changed the toString > method to: > > @Override > public String toString() { > // Quick shortcut > if (isEmpty()) { > return EMPTY; > } > // Setup a json output via code, avoiding to include JSON > artifacts dependencies > StringBuilder sb = new StringBuilder(""); > String prefix = ""; > for (Map.Entry<String, String> entry : entrySet()) { > sb.append(prefix); > sb.append(doubleQuoteString(entry.getKey())) > .append("=>") > .append(doubleQuoteString(entry.getValue())); > prefix = ","; > } > return sb.toString(); > } > > this causes the insert statement to succeed and the HStore value specified > correctly. > > On Thu, Oct 14, 2021 at 10:16 PM Alessandro Ferrucci < > alessandroferru...@gmail.com> wrote: > >> I checked this against GeoTools 26.0 and the same issue exists there. >> >> On Thu, Oct 14, 2021 at 9:57 PM Alessandro Ferrucci < >> alessandroferru...@gmail.com> wrote: >> >>> OK - so I stepped through the code. >>> >>> When it comes to encoding the HStore value, FilterToSQL.java goes into >>> >>> protected void writeLiteral(Object literal) throws IOException >>> >>> and there is no block there to handle HStore data type, so it ends up >>> essentially utilizing HStore.toString ( which outputs the object as JSON ). >>> >>> I am using GeoTools 22-RC >>> >>> On Thu, Oct 14, 2021 at 9:30 PM Alessandro Ferrucci < >>> alessandroferru...@gmail.com> wrote: >>> >>>> Hello - >>>> >>>> I am attempting to insert features into a PostGIS table. I create my >>>> feature types from the postgis table itself and construct the features from >>>> that. One of the feature attributes is an hstore attribute. The schema is >>>> being correctly read from the PostGIS table and GeoTools is correctly able >>>> to build a feature type where the attribute is an hstore object type. >>>> >>>> When it comes to constructing the SQL statements, the PostGIS dialect >>>> plugin is inserting the hstore attribute as such: >>>> >>>> '{"PROP_1": "VALUE_1", "PROP_2":"VALUE_2"}' >>>> >>>> However - this is incorrect syntax for specifying an hstore value in >>>> Postgres. >>>> >>>> The correct syntax is: >>>> >>>> ' "PROP_1" => "VALUE_1", "PROP_2" => "VALUE_2"' >>>> >>>> Is this a known bug or am I missing something? >>>> >>>> >>> >>> -- >>> Signed, >>> Alessandro Ferrucci >>> >> >> >> -- >> Signed, >> Alessandro Ferrucci >> > > > -- > Signed, > Alessandro Ferrucci > -- Signed, Alessandro Ferrucci
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users