MySqlConnector
MySqlConnector copied to clipboard
Type-mapping plugin API
npgsql supports a "type-mapping plugin" API which can be used to override or extend the library's built-in mappings between postgresql data types and CLR types. For example, the Npgsql.NodaTime plugin adds support to allow postgresql date/time types to be decoded directly into instances of the corresponding NodaTime types: https://www.npgsql.org/doc/types/nodatime.html
This feature is especially useful for preserving correctness / intent of the original data when there's no equivalent CLR type. To use the NodaTime example again, MySqlConnector will currently translate a mysql Date
column into the .NET DateTime
type, but that's not quite correct: a DateTime
represents an instant in time, but a Date represents a granularity of one day so is more interval-like (which is represented by the NodaTime LocalDate
struct).
A type-mapping plugin API in MySqlConnector would allow some of the edge cases or specialized column types to be handled better (or customized, if needed) without adding more complexity or library dependencies to the core MySqlConnector library.
Related cases (that could probably all be solved with a well-designed plugin API):
- Custom data types - https://github.com/mysql-net/MySqlConnector/issues/123
- Spatial data types: https://github.com/mysql-net/MySqlConnector/issues/70
- Utf8String - https://github.com/mysql-net/MySqlConnector/issues/618