-
Notifications
You must be signed in to change notification settings - Fork 358
adding doc for cli commands to add/update storedProcedure/view #912
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
Merged
Aniruddh Munde (Aniruddh25)
merged 7 commits into
main
from
dev/abhishekkuma/update-cli-doc-with-stored-procedure-commands
Oct 31, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a358c0a
adding doc for cli commands to add/up-date storedProcedure/view
527544e
Merge branch 'main' into dev/abhishekkuma/update-cli-doc-with-stored-…
abhishekkumams a529526
updating getting-started docs
27e06e0
Merge branch 'main' into dev/abhishekkuma/update-cli-doc-with-stored-…
abhishekkumams ba3e2b8
Merge branch 'main' into dev/abhishekkuma/update-cli-doc-with-stored-…
abhishekkumams 93895f8
updating examples
c9b3445
Merge branch 'main' into dev/abhishekkuma/update-cli-doc-with-stored-…
Aniruddh25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
docs/internals/UsingCliForAddingStored-proceduresAndViews.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| # Adding Views/Stored-Procedure to Runtime Config JSON | ||
|
|
||
| ## New Options | ||
| - CLI supports some new command line options (for `add` and `update` command): | ||
| - `--source.type` -> To Specify the type of source (tables, views, and stored-procedure), | ||
| - `--source.params` -> To Specify parameters for Stored Procedure, | ||
| - `--source.key-fields` -> To Specify key-fields for Table/Views. | ||
|
|
||
| ## Usage | ||
| ### When `source.type` is not provided | ||
| `dab add MyEntity --source "dbo.my_entity" --permissions "anonymous:*"` | ||
| NOTE: By Default sourceType is inferred to be table. | ||
| > preview: | ||
| ```json | ||
| "MyEntity": { | ||
| "source": "dbo.my_entity", | ||
| "permissions": [ | ||
| { | ||
| "role": "anonymous", | ||
| "actions": [ "create", "read", "update" ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### When `source.type` is stored-procedure | ||
| `dab add MyEntity --source "s001.book" --source.type "stored-procedure" --source.params "param1:123,param2:hello,param3:true" --permissions "anonymous:*"` | ||
| **NOTE**: source-params are optional if the procedure doesn't take any params. | ||
| > preview: | ||
| ```json | ||
| "MyEntity": { | ||
| "source": { | ||
| "type": "stored-procedure", | ||
| "object": "s001.book", | ||
| "parameters": { | ||
| "param1": 123, | ||
| "param2": "hello", | ||
| "param3": true | ||
| } | ||
| }, | ||
| "permissions": [ | ||
| { | ||
| "role": "anonymous", | ||
| "actions": [ "read" ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### When `source.type` is view | ||
| `dab add MyEntity --source "s001.book" --source.type "view" --source.key-fields "col1,col2" --permissions "anonymous:*"` | ||
|
abhishekkumams marked this conversation as resolved.
|
||
|
|
||
| **NOTE**: key-fields are optional if the view is simple and keys are inferable | ||
| > preview: | ||
| ```json | ||
| "MyEntity": { | ||
| "source": { | ||
| "type": "view", | ||
| "object": "s001.book", | ||
| "key-fields": [ "col1", "col2" ] | ||
| }, | ||
| "permissions": [ | ||
| { | ||
| "role": "anonymous", | ||
| "actions": [ "read" ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## Some unique Cases: | ||
| ### Conversion from one DatabaseObjectSource to another. | ||
| If the source object looks like this: | ||
| ```json | ||
| { | ||
| "object": "bookSp", | ||
| "type": "stored-procedure", | ||
| "parameters": { | ||
| "param1": "hello", | ||
| "param2": 123 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| and suppose we want to make it a table, then we need to run this command: | ||
| `dab update Book --bookTable --source.type table --source.key-fields "col1,col2"` | ||
|
|
||
| Result: | ||
| ```json | ||
| { | ||
| "object": "bookTable", | ||
| "type": "table", | ||
| "key-fields":["col1", "col2"] | ||
| } | ||
| ``` | ||
| We can convert it back to the original one by the below command: | ||
| `dab update Book --source bookSp --source.type stored-procedure --source.parameters "param1:hello,param2:123"` | ||
|
|
||
| **NOTE:** | ||
| The CLI recognizes redundant fields, i.e., Parameters for table/view, and keyFields for Stored Procedures. | ||
| When a user converts a table to a stored procedure, the CLI automatically sets the keyFields property to `null`. Similarly, the CLI sets the Parameters property to `null` when converting from a stored procedure to a table or view. | ||
| When a user explicitly sets the Parameters option while converting from stored-procedure to table/view, the CLI will return an error. The CLI will similarly return an error when a user sets the keyFields option when converting from a table/view to a stored procedure. | ||
|
|
||
| ### Conversion from object to String. | ||
| suppose we want to change the initial storedProcedure object to just a string object. | ||
| `dab update Book --source bookTable --source.type table` | ||
|
|
||
| Result: | ||
|
abhishekkumams marked this conversation as resolved.
|
||
| ```json | ||
| { | ||
| "source": "bookTable" | ||
| } | ||
| ``` | ||
| **NOTE:** | ||
| If the user changes from stored-procedure to table without adding keyfields then it automatically converts the value of `source` to string object from `DatabaseObjectSource` to represent the default source type of table. | ||
|
|
||
| When we run the following command to update the above stored-procedure: | ||
| `dab update Book --source bookView --source.type view` | ||
|
|
||
| Result: | ||
| ```json | ||
| { | ||
| "object": "bookView", | ||
| "type": "view" | ||
| } | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.