Skip to content

SqlLogin: add language parameter#2447

Merged
johlju merged 4 commits intodsccommunity:mainfrom
cai-n:add_language_to_sql_login
Feb 8, 2026
Merged

SqlLogin: add language parameter#2447
johlju merged 4 commits intodsccommunity:mainfrom
cai-n:add_language_to_sql_login

Conversation

@cai-n
Copy link
Contributor

@cai-n cai-n commented Feb 5, 2026

Pull Request (PR) description

Add the parameter Language to SqlLogin to allow setting the default language used by the login.

This Pull Request (PR) fixes the following issues

None

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@cai-n cai-n requested review from a team and johlju as code owners February 5, 2026 16:53
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Walkthrough

Adds a new Language property to the SqlLogin DSC resource: schema updated, implementation updated to accept/return/validate Language in Get/Set/Test-TargetResource, localization string added, and unit tests extended to cover Language propagation.

Changes

Cohort / File(s) Summary
Schema Definition
source/DSCResources/DSC_SqlLogin/DSC_SqlLogin.schema.mof
Added Language property (String, [Write]) with description "Specifies the default language."
Resource Implementation
source/DSCResources/DSC_SqlLogin/DSC_SqlLogin.psm1
Added Language parameter to Get-TargetResource (returns Language), Set-TargetResource (accepts/applies Language), and Test-TargetResource (validates Language); update/create paths now consider and assign Login.Language alongside DefaultDatabase.
Unit Tests
tests/Unit/DSC_SqlLogin.Tests.ps1
Extended mocks and assertions to include Language (e.g., 'us_english') across Get/Test/Set scenarios; verify Language is passed to creation/update flows and present on mocked SMO.Login objects.
Localization
source/DSCResources/DSC_SqlLogin/en-US/DSC_SqlLogin.strings.psd1
Added WrongLanguage localization key used when login default language differs from desired value.
Changelog
CHANGELOG.md
Documented addition of Language parameter to the public SqlLogin surface.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant DSC as "DSC Engine"
participant Resource as "DSC_SqlLogin Module"
participant SMO as "SQL Server (SMO)"
DSC->>Resource: Invoke Set-TargetResource(Name, DefaultDatabase, Language, ...)
Resource->>SMO: Query existing Login(Name)
SMO-->>Resource: Return Login object (may include Language)
alt Login missing
Resource->>SMO: New-SQLServerLogin(Name, DefaultDatabase, Language)
SMO-->>Resource: Created Login
else Login exists and differs
Resource->>SMO: Update-SQLServerLogin(Name, DefaultDatabase, Language)
SMO-->>Resource: Updated Login
end
Resource-->>DSC: Return result

mermaid
sequenceDiagram
participant DSC as "DSC Engine"
participant Resource as "DSC_SqlLogin Module"
participant SMO as "SQL Server (SMO)"
DSC->>Resource: Invoke Test-TargetResource(Name, DefaultDatabase, Language)
Resource->>SMO: Query existing Login(Name)
SMO-->>Resource: Return Login (includes Language)
alt Language matches & other props match
Resource-->>DSC: InDesiredState (True)
else
Resource-->>DSC: NotInDesiredState (False) + WrongLanguage message
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a Language parameter to the SqlLogin resource, which aligns with the changeset.
Description check ✅ Passed The description directly addresses the changeset, explaining that the Language parameter is being added to SqlLogin to allow setting the default language for logins.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 25-26: Update the CHANGELOG entry for SqlLogin to follow
formatting rules: make the resource name italic (use _SqlLogin_), bold the
parameter name (use **Language**), ensure the description line is wrapped to
under 80 characters, and if there is an associated issue append the standard
issue link format (e.g., [issue
`#NNNN`](https://github.com/<owner>/<repo>/issues/<issue_number>)) at the end of
the entry; locate the current entry referencing SqlLogin and Language to apply
these changes.

In `@source/DSCResources/DSC_SqlLogin/DSC_SqlLogin.psm1`:
- Around line 485-491: The Test-TargetResource function's comment-based help is
missing a .PARAMETER entry for the new Language parameter; update the help block
for Test-TargetResource to add a .PARAMETER Language section that briefly
describes the Language parameter's purpose (e.g., the login's default language),
its type (String), and any accepted values or default behavior so documentation
includes all parameters.

In `@tests/Unit/DSC_SqlLogin.Tests.ps1`:
- Around line 768-799: The test asserts that New-SQLServerLogin receives a
Login.Language value, but Set-TargetResource applies Language via
Update-SQLServerLogin after creation; update the tests to assert
Update-SQLServerLogin is invoked with $Login.Language -eq 'Français' (instead of
New-SQLServerLogin) for the two language-creation contexts, or alternatively
change Set-TargetResource implementation to set Language before calling
New-SQLServerLogin; reference the Set-TargetResource call path and replace the
Should -Invoke check that targets New-SQLServerLogin with an equivalent Should
-Invoke check targeting Update-SQLServerLogin (and keep the Connect-SQL
invocation assertion).

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (a4cc440) to head (cbfb165).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2447   +/-   ##
=====================================
  Coverage     94%     94%           
=====================================
  Files        227     227           
  Lines      10788   10801   +13     
=====================================
+ Hits       10159   10172   +13     
  Misses       629     629           
Flag Coverage Δ
unit 94% <100%> (+<1%) ⬆️
Files with missing lines Coverage Δ
source/DSCResources/DSC_SqlLogin/DSC_SqlLogin.psm1 100% <100%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@source/DSCResources/DSC_SqlLogin/DSC_SqlLogin.psm1`:
- Around line 559-563: Add the missing localized key WrongLanguage to the
resource strings file used by DSC_SqlLogin (the en-US .strings.psd1 for
DSC_SqlLogin): create an entry named WrongLanguage with a format string that
mirrors existing keys (e.g., "The login '{0}' has the language '{1}', but
expected it to have the language '{2}'.") so the call to
$script:localizedData.WrongLanguage in DSC_SqlLogin.psm1 resolves correctly;
follow the same key/value syntax and placement as other keys like
WrongDefaultDatabase.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@source/DSCResources/DSC_SqlLogin/en-US/DSC_SqlLogin.strings.psd1`:
- Line 22: Rename the localization key WrongLanguage to use underscores (e.g.,
Wrong_Language) in DSC_SqlLogin.strings.psd1 and update every reference to that
key throughout the codebase (resource accessors, tests, callers, and any
Get-LocalizedString/LoadString usages) to the new key name so localization
lookup continues to work; ensure the placeholder order/format
('{0}','{1}','{2}') remains unchanged when updating references.

@johlju johlju added the needs review The pull request needs a code review. label Feb 5, 2026
Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

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

:lgtm:

@johlju reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @cai-n).

@johlju johlju added ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. and removed needs review The pull request needs a code review. labels Feb 8, 2026
@johlju johlju merged commit 26616c7 into dsccommunity:main Feb 8, 2026
60 checks passed
@johlju
Copy link
Member

johlju commented Feb 8, 2026

Great work on this!

@johlju johlju removed the ready for merge The pull request was approved by the community and is ready to be merged by a maintainer. label Feb 8, 2026
@cai-n cai-n deleted the add_language_to_sql_login branch February 9, 2026 10:50
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.

2 participants