Skip to content

Tag import matches tags differently than the database #956

Open

Description

@mgwozdz-unicon

Description drafted by Claude:

TagImportPlan in src/openedx_tagging/import_export/import_plan.py decides in Python whether a file row's id names an existing tag, by comparing external_id.casefold(). The database decides the same question with the column collation, and the two disagree: casefold() matches more than SQLite's NOCASE (for example Straße and STRASSE) and less than MySQL's utf8mb4_unicode_ci (for example Café and Cafe).

Three places are affected: _existing_tags(), _end_state(), and the replace sweep in generate_actions(). The checks that compare one file row to another can stay as they are, because those ids are not in the database yet.

Known failures, as reported in the linked comments. They were not reproduced again for this issue:

Likely fix, from the first comment linked above: have the replace sweep ask the database which existing tags the file names, with one external_id__in query per chunk of rows, and key the existing-tag lookup by primary key so that _end_state() resolves each row's tag through the database. Add regression tests for the three cases above.

Asked for during review of #927. The code predates that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions