Skip to content

Challenge 6: mssql.UNIQUEIDENTIFIER not mapped to a UUID generator in make.py #98

@myyong

Description

@myyong

Problem

_COLUMN_TYPE_TO_GENERATOR_INFO in datafaker/make.py mapped postgresql.UUID to a UUID generator, but did not map mssql.UNIQUEIDENTIFIER.

This caused two failure modes:

  1. MS-SQL source → orm.yaml → any target: When datafaker introspects an MS-SQL source database, UNIQUEIDENTIFIER columns are reflected by SQLAlchemy as mssql.UNIQUEIDENTIFIER. Because that type was absent from _COLUMN_TYPE_TO_GENERATOR_INFO, _get_info_for_column_type returned None. The column either received no generator or fell back to the generic string generator, producing invalid UUID-shaped values.

  2. PostgreSQL source → orm.yaml → MS-SQL target: When the type parser reconstructed a UNIQUEIDENTIFIER column from an orm.yaml (type string "UNIQUEIDENTIFIER"), it produced mssql.UNIQUEIDENTIFIER. The same missing-entry problem applied.

Root cause

_COLUMN_TYPE_TO_GENERATOR_INFO was initialised with postgresql.UUID but not with mssql.UNIQUEIDENTIFIER, so the generator lookup failed for every UNIQUEIDENTIFIER column in an MS-SQL schema.

Steps to fix

  1. Import mssql from sqlalchemy.dialects in make.py (if not already present).
  2. Add an entry to _COLUMN_TYPE_TO_GENERATOR_INFO:
    mssql.UNIQUEIDENTIFIER: GeneratorInfo(
        generator="generic.cryptographic.uuid",
    ),
  3. Add a unit test that verifies _get_info_for_column_type(mssql.UNIQUEIDENTIFIER) returns a GeneratorInfo with the UUID generator.

Resolution

This fix was applied in commit 76fec75 as part of the broader MS-SQL type-parser and generator work for challenge 4.

The entry now sits alongside postgresql.UUID and sqltypes.Uuid in _COLUMN_TYPE_TO_GENERATOR_INFO (see datafaker/make.py).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions