Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/added-sqldatabase-creationpayload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: added
body: Add SQL Database creationPayload support for mkdir command with mode, backupRetentionDays, and collation parameters
time: 2026-03-13T00:00:00.000000000Z
custom:
Author: dzsquared
AuthorLink: https://github.com/dzsquared
4 changes: 4 additions & 0 deletions src/fabric_cli/errors/mkdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ def workspace_capacity_not_found() -> str:
@staticmethod
def folder_name_exists() -> str:
return "A folder with the same name already exists"

@staticmethod
def invalid_parameter_format(invalidParam: str, expectedFormat: str) -> str:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In Python, snake_case is the convention of writing names in all lowercase with words separated by underscores

Suggested change
def invalid_parameter_format(invalidParam: str, expectedFormat: str) -> str:
def invalid_parameter_format(invalid_param: str, expected_data_type: str) -> str:

return f"Invalid parameter format: '{invalidParam}'. Expected format: {expectedFormat}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return f"Invalid parameter format: '{invalidParam}'. Expected format: {expectedFormat}"
return f"Invalid parameter data type: '{invalidParam}'. Expected data type: {expected_data_type}"

25 changes: 25 additions & 0 deletions src/fabric_cli/utils/fab_cmd_mkdir_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,29 @@ def add_type_specific_payload(item: Item, args, payload):
]
}

case ItemType.SQL_DATABASE:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what about restore creation payload?

_mode = params.get("mode")
_backup_retention_days = params.get("backupretentiondays")
_collation = params.get("collation")

if _mode or _backup_retention_days or _collation:
creation_payload: dict = {"creationMode": _mode if _mode else "new"}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why we assume if creatIonmode not specified it should be 'new'? isn't it a required parameter for creationPayload?

if _backup_retention_days:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

will not run the conversion if the value is "0" or 0, because both are falsy. That means:

• "0" → skipped entirely
• 0 → skipped entirely

use

if _backup_retention_days is not None:
    try:
        creation_payload["backupRetentionDays"] = int(_backup_retention_days)
    except (ValueError, TypeError):
        raise FabricCLIError(
            ErrorMessages.Mkdir.invalid_parameter_format(
                _backup_retention_days, "integer"
            ),
            fab_constant.ERROR_INVALID_INPUT,
        )

try:
creation_payload["backupRetentionDays"] = int(
_backup_retention_days
)
except ValueError:
raise FabricCLIError(
ErrorMessages.Mkdir.invalid_parameter_format(
_backup_retention_days, "integer"
),
fab_constant.ERROR_INVALID_INPUT,
)
if _collation:
creation_payload["collation"] = _collation
payload_dict["creationPayload"] = creation_payload

return payload_dict


Expand Down Expand Up @@ -309,6 +332,8 @@ def get_params_per_item_type(item: Item):
optional_params = ["semanticModelId"]
case ItemType.MOUNTED_DATA_FACTORY:
required_params = ["subscriptionId", "resourceGroup", "factoryName"]
case ItemType.SQL_DATABASE:
optional_params = ["mode", "backupRetentionDays", "collation"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why mode not required?


return required_params, optional_params

Expand Down
2 changes: 2 additions & 0 deletions tests/test_commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
["Latin1_General_100_CI_AS_KS_WS_SC_UTF8"]),
(ItemType.WAREHOUSE, "", ["Latin1_General_100_BIN2_UTF8"]),
(ItemType.REPORT, "", ["_auto"]),
(ItemType.SQL_DATABASE, "backupRetentionDays=21,collation=SQL_Latin1_General_CP1_CS_AS",
["backupRetentionDays", "collation"]),
])

mv_item_to_item_success_params = pytest.mark.parametrize("item_type", [
Expand Down
Loading
Loading