Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1dd9f0f
Added field section for entities
anushakolan Oct 22, 2025
49e6ec2
Fotmat fix
anushakolan Oct 22, 2025
aa5472a
Test fix
anushakolan Oct 22, 2025
3d66a13
Test fix
anushakolan Oct 22, 2025
16e11fe
Fix test
anushakolan Oct 22, 2025
c1e43d0
Added debuglogs
anushakolan Oct 22, 2025
5493ef8
Added debuglogs 2
anushakolan Oct 22, 2025
496ca62
Added debug logs
anushakolan Oct 23, 2025
e3d5955
Added debuglogs 3
anushakolan Oct 23, 2025
efe9d92
Added debuglogs 4
anushakolan Oct 23, 2025
474aaf5
Added debuglogs 5
anushakolan Oct 23, 2025
84b588b
Main bug fix
anushakolan Oct 23, 2025
90388ee
Main bug fix 2
anushakolan Oct 23, 2025
939c038
Test fix
anushakolan Oct 23, 2025
5921193
Added updated postgres snapshot
anushakolan Oct 23, 2025
de7fc51
test fix
anushakolan Oct 23, 2025
49dd3cc
Test Fixes
anushakolan Oct 23, 2025
16cb8d5
Merge branch 'main' of https://github.com/Azure/data-api-builder into…
souvikghosh04 Oct 23, 2025
c5558c9
Major bug fix regarding pk alias issue
anushakolan Oct 23, 2025
d7253e7
Bug fixes
anushakolan Oct 23, 2025
713a1f9
Bug fix
anushakolan Oct 24, 2025
9b2cf6d
Fix
anushakolan Oct 24, 2025
6b7f62c
fix 2
anushakolan Oct 24, 2025
61a0d2d
Cleanup
anushakolan Oct 24, 2025
3de8575
Cleanup 1
anushakolan Oct 24, 2025
66e5e79
Cleanup 3
anushakolan Oct 24, 2025
89dd7f3
Test fix
anushakolan Oct 24, 2025
7c81665
Backmerge + conflicts resolved
souvikghosh04 Oct 24, 2025
6cd1c7c
Backmerge + conflicts resolved
souvikghosh04 Oct 24, 2025
c9d52e4
Merge branch 'dev/anushakolan/mcp/add-field-description-new' of https…
souvikghosh04 Oct 24, 2025
798da08
Updated snapshots
anushakolan Oct 24, 2025
a4e5dfa
Snapshot fix 2
anushakolan Oct 24, 2025
2c8d488
Snapshot update 3
anushakolan Oct 24, 2025
ef19e6d
Snapshot 3
anushakolan Oct 24, 2025
a932750
Snapshot fix
anushakolan Oct 24, 2025
2d93860
snapshot
anushakolan Oct 24, 2025
72b9da9
Description fix
anushakolan Oct 24, 2025
d526c1f
Snapshot
anushakolan Oct 24, 2025
aa5ca99
Last fix
anushakolan Oct 24, 2025
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
32 changes: 31 additions & 1 deletion schemas/dab.draft.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,21 @@
}
]
},
"fields": {
"type": "array",
"description": "Defines the fields (columns) exposed for this entity, with metadata.",
"items": {
"type": "object",
"properties": {
"name": { "type": "string", "description": "Database column name." },
"alias": { "type": "string", "description": "Exposed name for the field." },
"description": { "type": "string", "description": "Field description." },
"primary-key": { "type": "boolean", "description": "Indicates whether this field is a primary key." }
},
"required": ["name"]
},
"uniqueItems": true
},
"rest": {
"oneOf": [
{
Expand Down Expand Up @@ -1116,7 +1131,22 @@
}
}
},
"required": ["source", "permissions"]
"required": ["source", "permissions"],
"allOf": [
{
"if": {
"required": ["fields"]
},
"then": {
"not": {
"anyOf": [
{ "required": ["mappings"] },
{ "properties": { "source": { "properties": { "key-fields": { } }, "required": ["key-fields"] } } }
]
}
}
}
]
}
}
}
Expand Down
78 changes: 65 additions & 13 deletions src/Cli.Tests/AddEntityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public Task AddNewEntityWhenEntitiesEmpty()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);
return ExecuteVerifyTest(options);
}
Expand Down Expand Up @@ -82,7 +86,11 @@ public Task AddNewEntityWhenEntitiesNotEmpty()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

string initialConfiguration = AddPropertiesToJson(INITIAL_CONFIG, GetFirstEntityConfiguration());
Expand Down Expand Up @@ -118,7 +126,11 @@ public void AddDuplicateEntity()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

string initialConfiguration = AddPropertiesToJson(INITIAL_CONFIG, GetFirstEntityConfiguration());
Expand Down Expand Up @@ -158,7 +170,11 @@ public Task AddEntityWithAnExistingNameButWithDifferentCase()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

string initialConfiguration = AddPropertiesToJson(INITIAL_CONFIG, GetFirstEntityConfiguration());
Expand Down Expand Up @@ -193,7 +209,11 @@ public Task AddEntityWithCachingEnabled()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

return ExecuteVerifyTest(options);
Expand Down Expand Up @@ -234,7 +254,11 @@ public Task AddEntityWithPolicyAndFieldProperties(
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

// Create VerifySettings and add all arguments to the method as parameters
Expand Down Expand Up @@ -271,7 +295,11 @@ public Task AddNewEntityWhenEntitiesWithSourceAsStoredProcedure()
parametersNameCollection: null,
parametersDescriptionCollection: ["This is a test parameter description."],
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

return ExecuteVerifyTest(options);
Expand Down Expand Up @@ -307,7 +335,11 @@ public Task TestAddStoredProcedureWithRestMethodsAndGraphQLOperations()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

return ExecuteVerifyTest(options);
Expand Down Expand Up @@ -339,7 +371,11 @@ public void AddEntityWithDescriptionAndVerifyInConfig()
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

string config = INITIAL_CONFIG;
Expand Down Expand Up @@ -398,7 +434,11 @@ public void TestAddNewEntityWithSourceObjectHavingValidFields(
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

RuntimeConfigLoader.TryParseConfig(INITIAL_CONFIG, out RuntimeConfig? runtimeConfig);
Expand Down Expand Up @@ -462,7 +502,11 @@ public Task TestAddNewSpWithDifferentRestAndGraphQLOptions(
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

VerifySettings settings = new();
Expand Down Expand Up @@ -502,7 +546,11 @@ public void TestAddStoredProcedureWithConflictingRestGraphQLOptions(
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

RuntimeConfigLoader.TryParseConfig(INITIAL_CONFIG, out RuntimeConfig? runtimeConfig);
Expand Down Expand Up @@ -545,7 +593,11 @@ public void TestAddEntityPermissionWithInvalidOperation(IEnumerable<string> perm
parametersNameCollection: null,
parametersDescriptionCollection: null,
parametersRequiredCollection: null,
parametersDefaultCollection: null
parametersDefaultCollection: null,
fieldsNameCollection: [],
fieldsAliasCollection: [],
fieldsDescriptionCollection: [],
fieldsPrimaryKeyCollection: []
);

RuntimeConfigLoader.TryParseConfig(INITIAL_CONFIG, out RuntimeConfig? runtimeConfig);
Expand Down
8 changes: 5 additions & 3 deletions src/Cli.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,11 @@ public void TestUpdateEntity()
CollectionAssert.AreEqual(new string[] { "todo_id" }, relationship.LinkingSourceFields);
CollectionAssert.AreEqual(new string[] { "id" }, relationship.LinkingTargetFields);

Assert.IsNotNull(entity.Mappings);
Assert.AreEqual("identity", entity.Mappings["id"]);
Assert.AreEqual("Company Name", entity.Mappings["name"]);
Assert.IsNotNull(entity.Fields);
Assert.AreEqual(2, entity.Fields.Count);
Assert.AreEqual(entity.Fields[0].Alias, "identity");
Assert.AreEqual(entity.Fields[1].Alias, "Company Name");
Assert.IsNull(entity.Mappings);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
MyEntity: {
Source: {
Object: s001.book,
Type: View,
KeyFields: [
col1,
col2
]
Type: View
},
Fields: [
{
Name: col1,
PrimaryKey: true
},
{
Name: col2,
PrimaryKey: true
}
],
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
MyEntity: {
Source: {
Object: s001.book,
Type: Table,
KeyFields: [
id,
name
]
Type: Table
},
Fields: [
{
Name: id,
PrimaryKey: true
},
{
Name: name,
PrimaryKey: true
}
],
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
MyEntity: {
Source: {
Object: s001.book,
Type: View,
KeyFields: [
col1,
col2
]
Type: View
},
Fields: [
{
Name: col1,
PrimaryKey: true
},
{
Name: col2,
PrimaryKey: true
}
],
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
Object: s001.book,
Type: stored-procedure
},
Fields: [
{
Name: id,
PrimaryKey: true
},
{
Name: name,
PrimaryKey: true
}
],
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
Object: MyTable,
Type: Table
},
Fields: [
{
Name: id,
Alias: Identity,
PrimaryKey: false
},
{
Name: name,
Alias: Company Name,
PrimaryKey: false
}
],
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Expand All @@ -53,11 +65,7 @@
}
]
}
],
Mappings: {
id: Identity,
name: Company Name
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@
Object: MyTable,
Type: Table
},
Fields: [
{
Name: Macaroni,
Alias: Mac & Cheese,
PrimaryKey: false
},
{
Name: region,
Alias: United State's Region,
PrimaryKey: false
},
{
Name: russian,
Alias: русский,
PrimaryKey: false
},
{
Name: chinese,
Alias: 中文,
PrimaryKey: false
}
],
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Expand All @@ -53,13 +75,7 @@
}
]
}
],
Mappings: {
chinese: 中文,
Macaroni: Mac & Cheese,
region: United State's Region,
russian: русский
}
]
}
}
]
Expand Down
Loading
Loading