data-api-builder
data-api-builder copied to clipboard
Add new cli configure options
Why make this change?
- Closes #2295
- This change will allow user to update data-source options.
- Also, it makes CLI more powerful and developer friendly.
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 |
String: MSSQL, PostgreSQL, CosmosDB_NoSQL, MySQL |
✅ | |
| data-source. connection-string |
String | ✅ | |
| data-source. options.database |
String | ✅ | |
| data-source. options.container |
String | ✅ | |
| data-source. options.schema |
String | ✅ | |
| 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?
- [x] End-End Tests
- [x] 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.gqlBreak the command
dab configure --data-source.database-type cosmosdb_nosqldab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql
/azp run
/azp run
/azp run
/azp run
/azp run
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.
And then another case. If the 2nd command also included the database-type command
1. dab configure --data-source.database-type cosmosdb_nosql2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gqlI 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?
Question with respect to breaking the command up
1. dab configure --data-source.database-type cosmosdb_nosql2. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gqlwhat 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_nosql2. dab configure --data-source.database-type mssql3. dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gqlAnd then another case. If the 2nd command also included the database-type command
1. dab configure --data-source.database-type cosmosdb_nosql2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gqlI 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.
And then another case. If the 2nd command also included the database-type command
1. dab configure --data-source.database-type cosmosdb_nosql2.dab configure --data-source.database-type mssql --data-source.options.database testdbname --data-source.options.schema testschema.gqlI 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_nosql2.dab configure --data-source.options.database testdbname --data-source.options.schema testschema.gql --data-source.database-type mssqlDoes this fail?
yes, because the options provided do not belong to mssql type.
/azp run