Skip to content

Add dab auto-config-simulate CLI command#3189

Merged
anushakolan merged 14 commits intomainfrom
copilot/add-cli-command-auto-config-simulate
Mar 9, 2026
Merged

Add dab auto-config-simulate CLI command#3189
anushakolan merged 14 commits intomainfrom
copilot/add-cli-command-auto-config-simulate

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

Why make this change?

Developers using autoentities needed a way to preview which database objects would be matched by their filter definitions before committing changes to the config.

What is this change?

New auto-config-simulate verb that connects to the MSSQL database, executes the autoentities pattern-match query for each filter definition, and outputs results.

New files:

  • src/Cli/Commands/AutoConfigSimulateOptions.cs — defines the auto-config-simulate verb with optional --output/-o flag
  • src/Cli.Tests/AutoConfigSimulateTests.cs — unit and integration tests for the simulate command

ConfigGenerator.cs additions:

  • TrySimulateAutoentities — loads config (with env-var resolution), validates MSSQL + autoentities present, opens a SqlConnection, and runs MsSqlQueryBuilder.BuildGetAutoentitiesQuery() for each defined filter using explicit SqlParameter instances with SqlDbType.NVarChar
  • WriteSimulationResultsToConsole — prints grouped output with match counts and aligned entity → schema.object lines
  • WriteSimulationResultsToCsvFile — writes RFC 4180-compliant CSV (values are properly quoted/escaped)
  • QuoteCsvValue — helper that wraps and escapes commas, quotes, and newlines in CSV fields

Program.cs: registers AutoConfigSimulateOptions in the parser.

How was this tested?

  • Integration Tests — AutoConfigSimulateTests.cs covers: filter matching a known table with console output, filter matching a known table with CSV file output, and filter matching no tables (all marked [TestCategory("MsSql")], skip gracefully when MSSQL_SA_PASSWORD is not set).
  • Unit Tests — AutoConfigSimulateTests.cs covers: no autoentities defined.

Sample Request(s)

Console output (default):

dab auto-config-simulate
AutoEntities Simulation Results

Filter: ProductTables
Matches: 3

Products  -> dbo.Products
Inventory -> dbo.Inventory
Pricing   -> dbo.Pricing

Filter: AnotherFilter
Matches: 0

(no matches)

CSV file output:

dab auto-config-simulate --output results.csv
filter_name,entity_name,database_object
ProductTables,Products,dbo.Products
ProductTables,Inventory,dbo.Inventory
ProductTables,Pricing,dbo.Pricing

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 3, 2026 19:29
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
…doc comment

Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CLI command dab auto-config-simulate Add dab autoentities-simulate CLI command Mar 3, 2026
@RubenCerna2079 RubenCerna2079 added this to the March 2026 milestone Mar 4, 2026
@RubenCerna2079 RubenCerna2079 changed the title Add dab autoentities-simulate CLI command Add dab auto-config-simulate CLI command Mar 5, 2026
@RubenCerna2079 RubenCerna2079 marked this pull request as ready for review March 7, 2026 00:37
Copilot AI review requested due to automatic review settings March 7, 2026 00:37
@github-project-automation github-project-automation bot moved this from Todo to Review In Progress in Data API builder Mar 9, 2026
…ateTests, fix tuple naming

Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
…le output, CSV output, no-match)

Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://api.nuget.org:443/DigiCertTrustedG4CodeSigningRSA4096SHA3842021CA1.crl
    • Triggering command: /usr/bin/dotnet dotnet build src/Cli.Tests/Cli.Tests.csproj --no-incremental -p:TreatWarningsAsErrors=false (http block)
  • http://api.nuget.org:443/DigiCertTrustedG4RSA4096SHA256TimeStampingCA.crl
    • Triggering command: /usr/bin/dotnet dotnet build src/Cli.Tests/Cli.Tests.csproj --no-incremental -p:TreatWarningsAsErrors=false (http block)
  • http://api.nuget.org:443/DigiCertTrustedG4TimeStampingRSA4096SHA2562025CA1.crl
    • Triggering command: /usr/bin/dotnet dotnet build src/Cli.Tests/Cli.Tests.csproj --no-incremental -p:TreatWarningsAsErrors=false (http block)
  • http://api.nuget.org:443/DigiCertTrustedRootG4.crl
    • Triggering command: /usr/bin/dotnet dotnet build src/Cli.Tests/Cli.Tests.csproj --no-incremental -p:TreatWarningsAsErrors=false (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@RubenCerna2079
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

…est per review feedback

Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
…per review feedback

Co-authored-by: Aniruddh25 <3513779+Aniruddh25@users.noreply.github.com>
@Aniruddh25
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@anushakolan anushakolan enabled auto-merge (squash) March 9, 2026 21:18
@anushakolan anushakolan merged commit 0bc68fd into main Mar 9, 2026
11 checks passed
@anushakolan anushakolan deleted the copilot/add-cli-command-auto-config-simulate branch March 9, 2026 21:44
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Data API builder Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants