driver.Valuer should have precedence over json.Marshaler when encoding for JSON columns
dedalusj opened this issue · comments
dedalusj commented
Describe the bug
When encoding a custom type for a JSON or JSONB column it seems that pgx checks for the json.Marshaler interface before checking for driver.Valuer. However the latter should have precedence since the implementation being present indicates the consumer wanted a specific serialisation for the DB.
Expected behavior
When encoding a custom type for a JSON or JSONB column if the driver implements both the driver.Valuer and json.Marshaler interfaces the first should be called.
Actual behavior
Currently when a type implements both interface the json.Marshaler is called instead.
Jack Christensen commented
Merged #1807.