Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new cli configure options #2330

Merged

Conversation

abhishekkumams
Copy link
Contributor

@abhishekkumams abhishekkumams commented Aug 11, 2024

Why make this change?

What is this change?

  • Introducing new options for configure command to update data-source options.
Configuration File Property Path CLI Flag Data Type Nullable
data-source.
database-type
--data-source.database-type String: MSSQL, PostgreSQL, CosmosDB_NoSQL, MySQL
data-source.
connection-string
--data-source.connection-string String
data-source.
options.database
--data-source.options.database String
data-source.
options.container
--data-source.options.container String
data-source.
options.schema
--data-source.options.schema String
data-source.
options.set-session-context
--data-source.options.set-session-context Boolean: true, false (default: false)

NOTES:

Certain properties that are specific to database can only be updated with the correct databaseType.
For Example: If the database type initially was MSSQL, and we give cosmosDBoptions without specifying the new dbType as cosmosDB_NoSQL, the command will fail.
For better usability, we will also allow users to first update the dbType to cosmosDB_NoSQL and then in a new command provide the cosmosDB specifig options, since using all the options in one command can be very long and errornous.

How was this tested?

  • End-End Tests
  • Unit Tests

Sample Request(s)

  • To update to mssql
    dab configure --data-source.database-type mssql --data-source.options.set-session-context true

  • To update to cosmosDB_NoSQL

    Single command

    dab configure --data-source.database-type cosmosdb_nosql --data-source.options.database testdbname --data-source.options.schema testschema.gql

    Break the command

    1. dab configure --data-source.database-type cosmosdb_nosql
    2. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql

@abhishekkumams
Copy link
Contributor Author

/azp run

@abhishekkumams
Copy link
Contributor Author

/azp run

Copy link
Contributor

@seantleonard seantleonard left a comment

Choose a reason for hiding this comment

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

Added some suggestions and clarification on tests. also some clarifying questions.

src/Cli.Tests/ConfigureOptionsTests.cs Show resolved Hide resolved
src/Cli/Commands/ConfigureOptions.cs Show resolved Hide resolved
src/Cli/Commands/ConfigureOptions.cs Outdated Show resolved Hide resolved
src/Cli/ConfigGenerator.cs Outdated Show resolved Hide resolved
src/Cli/ConfigGenerator.cs Show resolved Hide resolved
src/Cli.Tests/ConfigureOptionsTests.cs Show resolved Hide resolved
src/Cli.Tests/ConfigureOptionsTests.cs Show resolved Hide resolved
src/Cli.Tests/ConfigureOptionsTests.cs Outdated Show resolved Hide resolved
src/Cli.Tests/ConfigureOptionsTests.cs Outdated Show resolved Hide resolved
src/Cli.Tests/EndToEndTests.cs Show resolved Hide resolved
@abhishekkumams
Copy link
Contributor Author

/azp run

@abhishekkumams
Copy link
Contributor Author

/azp run

@abhishekkumams
Copy link
Contributor Author

/azp run

src/Cli/ConfigGenerator.cs Show resolved Hide resolved
src/Cli.Tests/ConfigureOptionsTests.cs Show resolved Hide resolved
@aaronburtle
Copy link
Contributor

aaronburtle commented Sep 10, 2024

Question with respect to breaking the command up

1. dab configure --data-source.database-type cosmosdb_nosql
2. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql

what happens if we put another command in between these 2, will it still accept the final command? If so, what happens if the command in between them changes the database-type to something other than cosmos?

so something like

1. dab configure --data-source.database-type cosmosdb_nosql
2. dab configure --data-source.database-type mssql
3. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql

And then another case. If the 2nd command also included the database-type command

1. dab configure --data-source.database-type cosmosdb_nosql
2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gql

I presume that all of the above would fail but just want to double check.

@aaronburtle
Copy link
Contributor

aaronburtle commented Sep 10, 2024

And then another case. If the 2nd command also included the database-type command

1. dab configure --data-source.database-type cosmosdb_nosql
2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gql

I presume that all of the above would fail but just want to double check.

Follow up question, for the case that I quoted. Does order of the options within the command itself here matter? So for example what if we send these 2 commands, and note that the changing of the dbtype to mssql happens at the end of the 2nd command

1. dab configure --data-source.database-type cosmosdb_nosql
2.dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql --data-source.database-type mssql

Does this fail?

Copy link
Contributor

@aaronburtle aaronburtle left a comment

Choose a reason for hiding this comment

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

LGTM! Just a comment about some code duplication in the tests, and then a question about some edge cases to make sure they get handled.

@abhishekkumams
Copy link
Contributor Author

Question with respect to breaking the command up

1. dab configure --data-source.database-type cosmosdb_nosql 2. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql

what happens if we put another command in between these 2, will it still accept the final command? If so, what happens if the command in between them changes the database-type to something other than cosmos?

so something like

1. dab configure --data-source.database-type cosmosdb_nosql 2. dab configure --data-source.database-type mssql 3. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql

And then another case. If the 2nd command also included the database-type command

1. dab configure --data-source.database-type cosmosdb_nosql 2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gql

I presume that all of the above would fail but just want to double check.

Yes, both the commands will fail. Every command gets checked for correct database-type. if that's changed in midway. it will error it out.

@abhishekkumams
Copy link
Contributor Author

And then another case. If the 2nd command also included the database-type command
1. dab configure --data-source.database-type cosmosdb_nosql
2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gql
I presume that all of the above would fail but just want to double check.

Follow up question, for the case that I quoted. Does order of the options within the command itself here matter? So for example what if we send these 2 commands, and note that the changing of the dbtype to mssql happens at the end of the 2nd command

1. dab configure --data-source.database-type cosmosdb_nosql 2.dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql --data-source.database-type mssql

Does this fail?

yes, because the options provided do not belong to mssql type.

@abhishekkumams
Copy link
Contributor Author

/azp run

@abhishekkumams abhishekkumams merged commit a8f335d into main Sep 10, 2024
7 checks passed
@abhishekkumams abhishekkumams deleted the dev/abhishekkuma/add-configure-data-source-cli-options branch September 10, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] dab configure --data-source in CLI
4 participants