data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

Add new cli configure options

Open abhishekkumams opened this issue 1 year ago • 2 comments
trafficstars

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
--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?

  • [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.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 avatar Aug 11 '24 12:08 abhishekkumams

/azp run

abhishekkumams avatar Aug 11 '24 12:08 abhishekkumams

/azp run

abhishekkumams avatar Aug 11 '24 13:08 abhishekkumams

/azp run

abhishekkumams avatar Aug 22 '24 13:08 abhishekkumams

/azp run

abhishekkumams avatar Aug 23 '24 05:08 abhishekkumams

/azp run

abhishekkumams avatar Sep 02 '24 08:09 abhishekkumams

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 avatar Sep 10 '24 01:09 aaronburtle

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?

aaronburtle avatar Sep 10 '24 02:09 aaronburtle

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 avatar Sep 10 '24 06:09 abhishekkumams

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 avatar Sep 10 '24 06:09 abhishekkumams

/azp run

abhishekkumams avatar Sep 10 '24 08:09 abhishekkumams