Skip to content

feat: enables backup retention and collation setting for SQL DB#189

Open
dzsquared wants to merge 3 commits intomicrosoft:mainfrom
dzsquared:dev/drskwier/sqldb-creationpayload
Open

feat: enables backup retention and collation setting for SQL DB#189
dzsquared wants to merge 3 commits intomicrosoft:mainfrom
dzsquared:dev/drskwier/sqldb-creationpayload

Conversation

@dzsquared
Copy link
Copy Markdown

@dzsquared dzsquared commented Mar 12, 2026

📥 Pull Request

✨ Description of new changes

fixes #148

edit: fantastic, I broke the tests while fighting with the formatter to avoid a huge changeset

@dzsquared dzsquared requested a review from a team as a code owner March 12, 2026 23:08
@dzsquared dzsquared marked this pull request as draft March 12, 2026 23:32
@dzsquared dzsquared marked this pull request as ready for review March 13, 2026 17:25
@dzsquared
Copy link
Copy Markdown
Author

hi @aviatco - can this be reviewed for the next release?


@staticmethod
def invalid_parameter_format(invalidParam: str, expectedFormat: 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}"

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:

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

]
}

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?

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?


if _mode or _backup_retention_days or _collation:
creation_payload: dict = {"creationMode": _mode if _mode else "new"}
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,
        )

rm(item_full_path)

# region SQL database
def test_mkdir_sqldatabase_without_params_success(
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.

redundant - already covered in test_mkdir_item_success. please remove the recording file as well

# Cleanup
rm(sqldb_full_path)

def test_mkdir_sqldatabase_partial_params_success(
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.

Please define another case in mkdir_item_with_creation_payload_success_params in conftest instead of adding new test.

# Assert failure due to invalid integer
assert_fabric_cli_error(constant.ERROR_INVALID_INPUT)

def test_mkdir_sqldatabase_explicit_mode_success(
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.

same as comment above - define this usecase in the conftest parameterize and remove this test and its recording

# Cleanup
rm(sqldb_full_path)

def test_mkdir_sqldatabase_param_discovery(
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.

should not be as e2e test, we should use the test_mkdir_utils you added and add the test there and remove the recording.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] [SQL database] Create new SQLDatabase with initial properties (backupRetentionDays, collation)

2 participants