Description
openedon Apr 12, 2024
#30981 shows that we're currently lacking test coverage for querying types within JSON. Our testing for specific database types is spread out across various places:
- BuiltInDataTypesTestBase: basic type testing support. Uses a single model, so quite difficult (even if possible) to extend for extra types beyond the initial closed list.
- JsonTypesTestBase: serialization/deserialization within JSON only - both scalars and collections - but not end-to-end (uses JsonValueReaderWriter), and no querying.
- JsonQueryTestBase: JSON querying tests, including query testing for a closed list of types (so not easily extensible by providers)
- JsonUpdateTestBase: JSON update tests, for the same closed list of types.
Ideally, we'd have one ad-hoc test suite, with infra to perform all testing for a given database type via a single test; the test would dynamically build an ad-hoc model with a regular column of the type, a JSON document with a scalar of the type, and a collection of the type; and it would exercise serialization, deserialization and querying of all of the above. The test class would contain testing for a basic type list, but providers would be able to easily call the same test infra method for their own arbitrary types. Opt outs would allow not testing specific aspects - like JSON serialization - where that happens to not be supported etc.
For inspiration, see the AssertType() infra in Npgsql (code), where a single call tests all functionality related to the support of a single type.