Skip to content

Conversation

ANeumann82
Copy link
Contributor

This adds support for the JSON_OBJECT(*) and JSON_OBJECT(t1.*, t2.*) syntax, reference is here: https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/JSON_OBJECT.html

While working on this, I noticed that the current handling is a bit off:
In OBJECT_POSTGRES mode, the separate entries are stored in key and value of a single keyValue, and the AllColumns and AllTableColumns-Objects would end up there as well.

As it is possible to mix actual key value pairs and AllTableColumns ( JSON_OBJECT(t1.*, 'name' : t2.name, t3.*) ) we need to make sure that each "entry" gets it's own KeyValuePair, with just the key (or value) set.

I'm not sure how breaking changes are handled here. The PR so far is binary compatible, i.e. the API is backwards compatible, but the behaviour changed slightly.

OBJECT_MYSQL and OBJECT_POSTGRES are not used anymore. Instead the JsonKeyValuePair now has a "separator"-Field that describes how the key and the value are rendered. There is one entry NOT_USED in case the KeyValuePair has only one value.

Open questions:

  • Should we store single entry keyValuePairs in the key or the value field. Value seems a bit more sane, but key is easier.
  • Is it ok to deprecate the old syntax ( JsonKeyValuePair.get/set/withValueKeyword, JsonFunctionType.OBJECT_MYSQL, etc.)? I assume they shouldn't simply be deleted.

I plan to work on this a bit more, also the JsonAggregateFunction should probably be adapted as well, but I'd like to get your opinion on the whole thing first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant