Skip to content

Change autoentities patterns.name default value#3472

Open
RubenCerna2079 wants to merge 4 commits intomainfrom
dev/rubencerna/fix-autoentity-name-property
Open

Change autoentities patterns.name default value#3472
RubenCerna2079 wants to merge 4 commits intomainfrom
dev/rubencerna/fix-autoentity-name-property

Conversation

@RubenCerna2079
Copy link
Copy Markdown
Contributor

@RubenCerna2079 RubenCerna2079 commented Apr 27, 2026

Why make this change?

What is this change?

This changes the default value of the patterns.name property inside autoentities so 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?

  • Integration Tests
  • Unit Tests
  • Manual Tests
    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.name property.

Sample Request(s)

"AllMagazineObjects": {
  "patterns": {
    "include": [
      "%.magazines"
    ]
  },
  "permissions": [
    {
      "role": "anonymous",
      "actions": [
        {
          "action": "*"
        }
      ]
    }
  ]
}
image image

Copilot AI review requested due to automatic review settings April 27, 2026 19:01
@RubenCerna2079 RubenCerna2079 added this to the April 2026 milestone Apr 27, 2026
@RubenCerna2079 RubenCerna2079 linked an issue Apr 27, 2026 that may be closed by this pull request
1 task
@RubenCerna2079 RubenCerna2079 moved this from Todo to In Progress in Data API builder Apr 27, 2026
@RubenCerna2079 RubenCerna2079 changed the title Change default patterns.name default value Change autoentities patterns.name default value Apr 27, 2026
@RubenCerna2079 RubenCerna2079 moved this from In Progress to Review In Progress in Data API builder Apr 27, 2026
Copy link
Copy Markdown
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

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.name from {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 narrowing patterns.include to just the two tables under test (e.g., foo.magazines and bar.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 PublisherAutoEntity is misleading in a test that is specifically about generating foo_magazines and bar_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 is patterns.name. Updating this avoids confusion when correlating the test with the CLI/schema docs.
                    publishers {
                        items {
                            id
                            name
                        }

Comment thread src/Service.Tests/Configuration/ConfigurationTests.cs
Comment thread src/Config/ObjectModel/AutoentityPatterns.cs
else
{
this.Name = "{object}";
this.Name = "{schema}_{object}";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Dependent on PR #3468

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

Labels

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Bug]: autoentities does not honor schema

4 participants