Change autoentities patterns.name default value#3472
Change autoentities patterns.name default value#3472RubenCerna2079 wants to merge 4 commits intomainfrom
patterns.name default value#3472Conversation
patterns.name default valuepatterns.name default value
There was a problem hiding this comment.
Pull request overview
Updates the autoentities default naming pattern so generated entity names include both schema and object, preventing collisions when multiple schemas contain objects with the same name (fix for #3455).
Changes:
- Changed the default
autoentities.patterns.namefrom{object}to{schema}_{object}. - Updated CLI option help text and JSON schema to reflect the new default.
- Added an MSSQL integration test to validate generation/access of same-named tables across different schemas.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Service.Tests/Configuration/ConfigurationTests.cs |
Adds a new MSSQL integration test covering same object name across schemas. |
src/Config/ObjectModel/AutoentityPatterns.cs |
Changes the default autoentity naming pattern to include schema + object. |
src/Cli/Commands/AutoConfigOptions.cs |
Updates patterns.name help text to match the new default. |
schemas/dab.draft.schema.json |
Updates schema description/default for autoentities.patterns.name. |
Comments suppressed due to low confidence (3)
src/Service.Tests/Configuration/ConfigurationTests.cs:5618
- This test passes
Include: null, which defaults to"%.%"and will auto-generate entities for all eligible tables in the test database. That makes the test slower and more brittle (future schema additions could introduce unrelated naming conflicts). Prefer narrowingpatterns.includeto just the two tables under test (e.g.,foo.magazinesandbar.magazines).
HttpResponseMessage graphqlResponse = await client.SendAsync(graphqlRequest);
// Assert
string expectedResponseFragment = @"{""id"":1156,""name"":""The First Publisher""}";
// Verify number of entities
src/Service.Tests/Configuration/ConfigurationTests.cs:5614
- The autoentity definition key/name
PublisherAutoEntityis misleading in a test that is specifically about generatingfoo_magazinesandbar_magazines. Renaming it to something magazines-focused will make failures and logs easier to interpret.
};
HttpResponseMessage graphqlResponse = await client.SendAsync(graphqlRequest);
src/Service.Tests/Configuration/ConfigurationTests.cs:5604
- The XML doc comment refers to the default
'property.name', but the configuration property ispatterns.name. Updating this avoids confusion when correlating the test with the CLI/schema docs.
publishers {
items {
id
name
}
| else | ||
| { | ||
| this.Name = "{object}"; | ||
| this.Name = "{schema}_{object}"; |
There was a problem hiding this comment.
Does this PR also fix the other issue where at the time discovery of metadata for autoentities, dbo is assumed to be the default schema to look for the underlying table? I had opened a different issue for that.
Aniruddh25
left a comment
There was a problem hiding this comment.
Dependent on PR #3468
Why make this change?
What is this change?
This changes the default value of the
patterns.nameproperty insideautoentitiesso that it uses both the {schema} and {object} in order to allow users to use multiple objects that have the same name but are from different schemas without the need to do additional changes to the config file.How was this tested?
Used sample below to ensure that different entities with the same object name but different schema name can be created without the need to change the
patterns.nameproperty.Sample Request(s)