mongodb / mongo-jdbc-driver

JDBC Driver for MongoDB Atlas SQL interface
Apache License 2.0
36 stars 33 forks source link

SQL-668: bsontype can be an array or a single String. #73

Closed nbagnard closed 2 years ago

nbagnard commented 2 years ago

This PR handles decoding schema where bsontype is either a Set or String. It also implements a logic for transforming sets of types in bsontype in a list of anyOf and flattening anyOfs.

The assumptions I made for this are:

pmeredit commented 2 years ago

This PR handles decoding schema where bsontype is either a Set or String. It also implements a logic for transforming sets of types in bsontype in a list of anyOf and flattening anyOfs.

The assumptions I made for this are:

  • { "bsonType": "bool", "additionalProperties": false } is not equals to { "bsonType": "bool", "additionalProperties": true } so the same type can be twice in the anyOf list if the other fields values are different.

It's still correct to have the same type twice, so I think this is a good simplifying assumption.

  • If bsonType is a set of types, there will be no duplicates. For example, no bsontype: [string, object, bool, object]
pmeredit commented 2 years ago

As a small comment, could we avoid removing new lines from the end of all the files? It messes up the PR. If that is something we want to do, we should do it in a separate PR. But I assume this was some IDE setting :)