Skip to content

Conversation

@anushakolan
Copy link
Contributor

@anushakolan anushakolan commented Jan 23, 2026

Why make this change?

When updating an entity with a command like: dab update Incident --fields.name "Id" --fields.description "Unique Key", the existing primary-key flag on Id was being changed to falseeven though no primary-key option was specified.
This change removes that surprise so primary-key metadata only changes when explicitly requested.

What is this change?

  • Adjusts the entity update logic so that:
  1. If the user does not provide any fields.primary-key option, existing primary-key flags for fields mentioned in fields.name are preserved.
  2. If the user does provide fields.primary-key, those true/false values are still applied positionally to the corresponding fields exactly as before.

-Adds a regression test that:

  1. Starts from a config where Id is already a primary key.
  2. Runs an update that only changes the description for Id via fields.name and fields.description.
  3. Verifies that the description changes and the primary-key flag on Id remains true.

How was this tested?

  • Integration Tests
  • Unit Tests
  1. Existing CLI unit tests for entity update.
  2. New regression test that validates primary-key is preserved when only the field description is updated.

Sample Request(s)

  • To demonstrate the fixed behavior:
  1. Initial state: Id is configured as a primary key on the entity.
  2. Command: dab update Incident --fields.name "Id" --fields.description "Unique Key 2"
  3. Result after this change:
  4. The description for Id becomes “Unique Key 2”.
  5. The primary-key flag for Id stays true.
  • To explicitly change primary keys (still supported):
  1. Set Id as primary key:
    dab update Incident --fields.name "Id" --fields.primary-key true

  2. Clear Id as primary key:
    dab update Incident --fields.name "Id" --fields.primary-key false

@anushakolan
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@anushakolan
Copy link
Contributor Author

/azp run

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a CLI dab update behavior where updating field metadata (e.g., description) unintentionally reset existing primary-key flags when --fields.primary-key was not provided.

Changes:

  • Preserve existing FieldMetadata.PrimaryKey values during field merges unless --fields.primary-key is explicitly supplied.
  • Add a regression unit test ensuring a field’s primary-key flag remains unchanged when only updating fields.description.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Cli/ConfigGenerator.cs Adjusts field merge logic to keep existing PrimaryKey unless the primary-key option was provided.
src/Cli.Tests/UpdateEntityTests.cs Adds a regression test verifying primary-key is preserved when updating only field description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Contributor

@JerryNixon JerryNixon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an additional test case for the inverse scenario: verify that when --fields.primary-key false IS explicitly provided, it correctly changes the flag from true to false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

BUG: CLI surprise behavior

3 participants