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:
return f"Invalid parameter format: '{invalidParam}'. Expected format: {expectedFormat}"
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:
_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"}
if _backup_retention_days:
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"]

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