You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metamodel.apache.org by "منصة شليله (Jira)" <ji...@apache.org> on 2020/08/25 20:21:00 UTC
[jira] [Commented] (METAMODEL-1223) PostgresqlQueryWriter not
support json array
[ https://issues.apache.org/jira/browse/METAMODEL-1223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17184726#comment-17184726 ]
منصة شليله commented on METAMODEL-1223:
---------------------------------------
(منصةسشليله)
SA Riyadh,2020/08/25
https://app.bugsnag.com/organizations/mjmw-at-ldwt-mns-at-shlylh/stability-center
> PostgresqlQueryWriter not support json array
> --------------------------------------------
>
> Key: METAMODEL-1223
> URL: https://issues.apache.org/jira/browse/METAMODEL-1223
> Project: Apache MetaModel
> Issue Type: Improvement
> Affects Versions: 5.3.1
> Reporter: jiangsong
> Priority: Blocker
>
> I use metamodel to explore my pg database, with one column as jsonarray like:
> {code:java}
> [
> {
> "points":[
> {
> "pixelX":601,
> "pixelY":997
> },
> {
> "pixelX":444,
> "pixelY":1532
> }
> ]
> },
> {
> "points":[
> {
> "pixelX":1057,
> "pixelY":982
> },
> {
> "pixelX":1183,
> "pixelY":1525
> }
> ]
> },
> {
> "points":[
> {
> "pixelX":1964,
> "pixelY":1510
> },
> {
> "pixelX":1650,
> "pixelY":971
> }
> ]
> }
> ]
> {code}
>
>
> while I get a exception, It seems this method read json value default as Map.class which is not right for jsonarray.
> are there any solution or workaround?
> thanks for help!
> {code:java}
> @Override
> public Object getResultSetValue(ResultSet resultSet, int columnIndex, Column column) throws SQLException {
> if (column.getNativeType() != null) {
> switch (column.getNativeType()) {
> case "json":
> case "jsonb":
> assert column.getType() == ColumnType.MAP;
> final String stringValue = resultSet.getString(columnIndex);
> if (stringValue == null) {
> return null;
> }
> try {
> _error line:_ return jsonObjectMapper.readValue(stringValue, Map.class);
> } catch (Exception e) {
> throw new IllegalArgumentException("Unable to read string as JSON: " + stringValue);
> }
> }
> }
> return super.getResultSetValue(resultSet, columnIndex, column);
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)