Skip to main content

column_equivalent

Function column_equivalent 

Source
pub fn column_equivalent(
    c: &DeclaredColumnContract,
    t: &CreateColumnDef,
) -> bool
Expand description

Returns true when a live current column and a target CreateColumnDef describe the same column shape.

Comparison rules (must mirror the no-op behavior of apply_alter_operations_to_contract):

  1. sql_type — primary identity. current.sql_type is Option; when None (legacy contract), fall back to comparing the legacy data_type string. Both sides None → use data_type.
  2. constraint flagsnot_null, unique, primary_key, compress must all match exactly.
  3. default — string compare after normalisation (trim + strip surrounding single quotes).
  4. enum_variants — exact ordered Vec match.
  5. array_element — string compare.
  6. decimal_precision — exact match.

Legacy data_type field is intentionally not compared when both sides have sql_typedata_type is derived from sql_type and may differ in case or aliasing without semantic impact.