Skip to content

Wrongly assumed data type when mixing UUIDs and Alphanums #72

Description

@vmatt

Description

When using a table with a mix of UUIDs and alphanumeric strings as primary keys, reladiff incorrectly assumes all primary keys are UUIDs. This causes the following error when sampling data:

packages/reladiff/diff_tables.py", line 322, in _parse_key_range_result
    raise type(e)(f"Cannot apply {key_types} to '{min_key_values}', '{max_key_values}'.") from e
ValueError: Cannot apply [String_UUID()] to '('0001aa71db2877006cc4fd051d96195f',)', '('system52923',)'.

The issue appears when the primary keys contain values that follow UUID format (like 0001aa71db2877006cc4fd051d96195f) alongside other alphanumeric values (like system52923) that cannot be parsed as UUIDs.

Environment

  • reladiff version: 0.6.0
  • OS: macOS
  • Database: PostgreSQL 15

Expected behavior

reladiff should handle mixed primary key formats correctly, potentially by using a more flexible type like String_Alphanum instead of assuming all keys are UUIDs.

Proposed solution

Is there a way to explicitly specify the primary key data type to enforce String_Alphanum or a similar more permissive type? Alternatively, could reladiff be enhanced to automatically fallback to a more general string type when UUID parsing fails?

Additional information

The issue occurs during data sampling when reladiff attempts to determine the primary key range. It appears that the type detection logic assumes homogeneous primary key types and fails when encountering mixed formats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions