Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: Cross-DBMS cohort database creation fails with collation errors #28

@jas88

Description

@jas88

Problem

When creating a cohort database from a prototype on a different DBMS type (e.g., SQL Server → MySQL or PostgreSQL), the operation fails with collation errors.

Current Behavior

The code in CreateNewCohortDatabaseWizard.cs (lines 116-132) attempts to preserve collation from source columns, but:

  • DBMS-specific collation names (e.g., Latin1_General_CI_AS on SQL Server vs latin1_swedish_ci on MySQL) are not compatible across systems
  • No translation or fallback logic exists for cross-DBMS scenarios
  • Results in errors like "collation 'latin1_swedish_ci' not found" when crossing DBMS boundaries

Expected Behavior

When target database DBMS differs from source column DBMS:

  • Either set Collation = null to use target database defaults
  • Or implement collation name translation between DBMS types

Related Files

  • Rdmp.Core/CohortCommitting/CreateNewCohortDatabaseWizard.cs:116-132
  • Rdmp.Core/Curation/Data/ColumnInfo.cs (Collation property)

Upstream Reference

Originally reported in HicServices/RDMP#1093 (marked high priority)

Suggested Fix

Add DBMS type check before applying collation:

// Only use collation if source and target are same DBMS type
var sourceDbms = e.ColumnInfo?.TableInfo?.Server?.DatabaseType;
var targetDbms = _targetDatabase.Server.DatabaseType;
Collation = (collations.Length == 1 && sourceDbms == targetDbms) ? collations[0] : null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions