Skip to content

In Postgres compatibility mode the NUMERIC type w/o scale should not default to 0 #3538

@fmurialdo

Description

@fmurialdo

As the Postgres documentation itself says "The SQL standard requires a default scale of 0". However Postgres made the choice to not follow the standard. When taking advantage of not specifying a scale in order to create an “unconstrained numeric” column for Postgres, this creates compatibility issues with H2. In Postgres compatibility mode, the behavior for NUMERIC in H2 should be more like DECFLOAT.

https://www.postgresql.org/docs/current/datatype-numeric.html

without any precision or scale creates an “unconstrained numeric” column in which numeric values of any length can be
stored, up to the implementation limits. A column of this kind will not coerce input values to any particular scale, whereas 
numeric columns with a declared scale will coerce input values to that scale. (The SQL standard requires a default scale 
of 0, i.e., coercion to integer precision. We find this a bit useless. If you're concerned about portability, always specify the 
precision and scale explicitly.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions