Context
dbkit supports same-type numeric +, -, and *, but does not model PostgreSQL's broader numeric promotion and operator matrix.
Scope
Mixed numeric promotion
Support PostgreSQL-valid pairs such as:
SMALLINT + INTEGER → INTEGER
INTEGER + BIGINT → BIGINT
REAL + DOUBLE PRECISION → DOUBLE PRECISION
Apply the same base-result matrix to +, -, and * in both supported operand directions.
Division and remainder
Add typed / and % expression support with PostgreSQL's result types and error behavior.
Conditional numeric functions
Use the common numeric type for calls such as:
COALESCE(integer_value, bigint_value)
GREATEST(smallint_value, integer_value)
LEAST(real_value, double_value)
Small integer widening
Allow i16 / Option<i16> in interval::days, hours, and minutes, where PostgreSQL widens SMALLINT to the INTEGER constructor argument.
Requirements
- Preserve
Option<Output> whenever any SQL-propagating operand is nullable.
- Reject numeric/non-numeric combinations at compile time.
- Centralize the promotion matrix rather than duplicating it per operator/function.
- Cover both operand directions and boundary types.
This is separate from #46, which corrects the already-supported SMALLINT op SMALLINT result, and #49, which covers aggregate SUM result types.
Context
dbkit supports same-type numeric
+,-, and*, but does not model PostgreSQL's broader numeric promotion and operator matrix.Scope
Mixed numeric promotion
Support PostgreSQL-valid pairs such as:
Apply the same base-result matrix to
+,-, and*in both supported operand directions.Division and remainder
Add typed
/and%expression support with PostgreSQL's result types and error behavior.Conditional numeric functions
Use the common numeric type for calls such as:
Small integer widening
Allow
i16/Option<i16>ininterval::days,hours, andminutes, where PostgreSQL widens SMALLINT to the INTEGER constructor argument.Requirements
Option<Output>whenever any SQL-propagating operand is nullable.This is separate from #46, which corrects the already-supported
SMALLINT op SMALLINTresult, and #49, which covers aggregateSUMresult types.