Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions src/Cli.Tests/UpdateEntityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,83 @@ public void TestUpdateFieldDescriptionPrimaryKeyBehavior(bool? primaryKeyFlag, b
Assert.AreEqual(expectedPrimaryKey, field.PrimaryKey);
}

/// <summary>
/// Verifies that a field description containing commas is stored in full
/// and not truncated at the first comma.
/// </summary>
[DataTestMethod]
[DataRow("Indicates whether the record is active. When false, the record may be historical and still exist, but is no longer actively used. Type: boolean",
DisplayName = "Field description with multiple commas is stored in full")]
[DataRow("Simple description without commas",
DisplayName = "Field description without commas is unchanged")]
public void TestUpdateFieldDescriptionWithCommas(string description)
{
string initialConfig = GetInitialConfigString() + "," + @"
""entities"": {
""MyEntity"": {
""source"": ""MyTable"",
""permissions"": [
{
""role"": ""anonymous"",
""actions"": [""read""]
}
]
}
}
}";

UpdateOptions options = new(
source: null,
permissions: null,
entity: "MyEntity",
sourceType: null,
sourceParameters: null,
sourceKeyFields: null,
restRoute: null,
graphQLType: null,
fieldsToInclude: null,
fieldsToExclude: null,
policyRequest: null,
policyDatabase: null,
relationship: null,
cardinality: null,
targetEntity: null,
linkingObject: null,
linkingSourceFields: null,
linkingTargetFields: null,
relationshipFields: null,
map: null,
cacheEnabled: null,
cacheTtlSeconds: null,
cacheLevel: null,
healthEnabled: null,
config: TEST_RUNTIME_CONFIG_FILE,
restMethodsForStoredProcedure: null,
graphQLOperationForStoredProcedure: null,
description: null,
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null,
fieldsNameCollection: new[] { "RecordIsActive" },
fieldsAliasCollection: null,
fieldsDescriptionCollection: new[] { description },
fieldsPrimaryKeyCollection: null,
mcpDmlTools: null,
mcpCustomTool: null
);

Assert.IsTrue(RuntimeConfigLoader.TryParseConfig(initialConfig, out RuntimeConfig? runtimeConfig), "Parsed config file.");
Assert.IsTrue(TryUpdateExistingEntity(options, runtimeConfig!, out RuntimeConfig updatedRuntimeConfig), "Successfully updated entity in the config.");

Entity updatedEntity = updatedRuntimeConfig.Entities["MyEntity"];
Assert.IsNotNull(updatedEntity.Fields);
Assert.AreEqual(1, updatedEntity.Fields!.Count);
FieldMetadata field = updatedEntity.Fields[0];
Assert.AreEqual("RecordIsActive", field.Name);
Assert.AreEqual(description, field.Description, "Full description including commas must be preserved.");
}

private static string GetInitialConfigString()
{
return @"{" +
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/Commands/EntityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public EntityOptions(
[Option("parameters.name", Required = false, Separator = ',', HelpText = "Comma-separated list of parameter names for stored procedure.")]
public IEnumerable<string>? ParametersNameCollection { get; }

[Option("parameters.description", Required = false, Separator = ',', HelpText = "Comma-separated list of parameter descriptions for stored procedure.")]
[Option("parameters.description", Required = false, HelpText = "List of parameter descriptions for stored procedure. Provide one value per parameter. Descriptions may contain commas.")]
public IEnumerable<string>? ParametersDescriptionCollection { get; }

[Option("parameters.required", Required = false, Separator = ',', HelpText = "Comma-separated list of parameter required flags (true/false) for stored procedure.")]
Expand All @@ -141,7 +141,7 @@ public EntityOptions(
[Option("fields.alias", Required = false, Separator = ',', HelpText = "Alias for the field.")]
public IEnumerable<string>? FieldsAliasCollection { get; }

[Option("fields.description", Required = false, Separator = ',', HelpText = "Description for the field.")]
[Option("fields.description", Required = false, HelpText = "Description for the field. Descriptions may contain commas.")]
public IEnumerable<string>? FieldsDescriptionCollection { get; }

[Option("fields.primary-key", Required = false, Separator = ',', HelpText = "Set this field as a primary key.")]
Expand Down