When loading a JSON export like:
jooq.loadInto(table)
.loadJSON(...)
.fields(field1, ..., fieldsN)
.execute();
you need to specify the fields even if the JSON already contains the field
information.
This seems unnecessary and brittle.
I made a proof of concept change to jOOQ which seems to work, at least for
my test cases.
I added LoaderJSONOptionsStep<R> fieldsFromJSON() to LoaderJSONStep
and an implementation to LoaderImpl that only sets a flag fieldsFromJSON:
@Override
public final LoaderImpl<R> fieldsFromJSON() {
this.fieldsFromJSON = true;
return this;
}
The only change needed to LoaderImpl.executeJSON() is to set fields to
source if the new fieldsFromJSON flag is set:
private void executeJSON() throws IOException {
...
source = r.fields(); // old
if(this.fieldsFromJSON) // new
fields = source; // new
...
}
The new JSON load looks like this:
jooq.loadInto(table)
.loadJSON(...)
.fieldsFromJSON()
.execute();
Please consider adding this feature to jOOQ.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jooq-user/0d5172c5-56a6-4f60-b7d0-ddd22f169583%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.