Skip to content

Fix: Duplicate Order values when adding new columns #29

Description

@jas88

Problem

When adding a new TableColumn/ExtractionInformation, the Order property defaults to 1 instead of automatically selecting the next available non-conflicting value, causing duplicate order IDs.

Current Behavior

New columns are created with Order = 1, resulting in:

  • Multiple columns with the same order value
  • Undefined/inconsistent column ordering in UI and queries
  • Potential data integrity issues

Expected Behavior

When creating a new column, the Order value should be automatically set to:

Order = existingColumns.Max(c => c.Order) + 1

Or if no existing columns: Order = 1

Impact

This is a data integrity bug that affects:

  • Column display order in UI
  • Export column ordering
  • Query result consistency

Related Files

Likely needs fixes in:

  • Rdmp.Core/Curation/Data/ColumnInfo.cs - Constructor/initialization
  • Rdmp.Core/Curation/Data/ExtractionInformation.cs - Constructor/initialization
  • Any repository methods that create new columns

Upstream Reference

Originally reported in HicServices/RDMP#1592

To Reproduce

  1. Create a catalogue with columns
  2. Add a new column through the UI or API
  3. Observe that new column has Order = 1 conflicting with existing column

Suggested Fix

In column creation logic, query existing columns and auto-assign next order:

// When creating new column
var maxOrder = existingColumns.Any() ? existingColumns.Max(c => c.Order) : 0;
newColumn.Order = maxOrder + 1;

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