Repository navigation
Members: Fix empty-string default constraints on cmsMember - #24358
AndyButland merged 3 commits into
Conversation
|
Hi there @nltgpeterskoglund, thank you for this contribution! 👍 While we wait for someone to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
There was a problem hiding this comment.
🟡 Changes recommended
The default-constraint lookup is not schema-scoped, so it can select another table’s constraint and block the upgrade; scope it to the target table’s object ID and add a two-schema regression test.
1 open issue
What changed in this PR
This PR corrects cmsMember defaults so fresh installs use empty strings rather than a single apostrophe, and repairs existing SQL Server databases during upgrade.
Changes:
- Corrects the
Email,LoginName, andPassworddefaults inMemberDto. - Registers an 18.5.0 migration to recreate SQL Server constraints; SQLite is unchanged.
- Adds integration tests covering fresh installs and existing, system-named, or missing constraints.
| File | Description |
|---|---|
tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/Upgrade/V_18_5_0/FixMemberEmptyStringDefaultsTests.cs |
Tests fresh-install defaults and migration scenarios. |
src/Umbraco.Infrastructure/Persistence/Dtos/MemberDto.cs |
Sets the three column defaults to empty strings. |
src/Umbraco.Infrastructure/Migrations/Upgrade/V_18_5_0/FixMemberEmptyStringDefaults.cs |
Recreates SQL Server default constraints with corrected values. |
src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs |
Adds the migration to the 18.5.0 upgrade chain. |
Review effort: Balanced
|
I'd be minded to simplify this @nltgpeterskoglund, and fix just the issue with the DTO so new installs get correct defaults. In practice it makes little sense to create a member without any of these fields, and we always provide them explicitly in Umbraco as you note, so these defaults never take effect. Your migration code looks good, but there may be edge cases on specific installs, and we'd have to handle it for 18, 19 and perhaps 17 too, with the complication of handling different upgrade paths. What do you think? |
…ty string Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cd0f874 to
6b727e9
Compare
cmsMember
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
As I hadn't heard back @nltgpeterskoglund, I've gone ahead and simplified this along the lines of my earlier comment, so it can go into the next release:
Thanks again for tracking this down. Your migration was well put together, it just didn't seem worth the upgrade risk for defaults that are never used. |

Prerequisites
Description
MemberDtodeclaresEmail,LoginNameandPasswordwith[Constraint(Default = "''")].FormatDefaultValuepasses the value throughGetQuotedValue, which wraps it in quotes again, so the constraint is created as:You can see this with
SELECT name, definition FROM sys.default_constraints WHERE parent_object_id = OBJECT_ID('cmsMember')on a fresh SQL Server install.This PR:
Default = "", so fresh installs getDEFAULT ('')FixMemberEmptyStringDefaults, which recreates the three constraints on SQL Server under their conventionalDF_cmsMember_*names. It followsSetDateDefaultsToUtcNowand handles both system-generated and missing constraints. SQLite is a no-op: altering a default there requires a table rebuild, and members always save explicit values for these columnsGetQuotedValueitself is left unchanged, to keep this PR minimal. Escaping'there would be a broader change for a separate discussion.This PR and #24331 both add an entry at the end of
UmbracoPlanunder// To 18.5.0, so whichever is merged second needs a trivial rebase.How to test
Fresh_Install_Has_Empty_String_Defaultsfails without the DTO change ("('''')") and passes with it.Can_Migrate_Single_Apostrophe_Defaults,…_System_Generated_Namesand…_Are_Missingcover the upgrade paths.SchemaValidationTest,MemberRepositoryTestandMemberServiceTestsstill pass on LocalDB.Local results:
SchemaValidationTest,MemberRepositoryTestandMemberServiceTestsall passed. The new fixture's own arrange assertion was fixed and its 4 tests were re-run green.🤖 Generated with Claude Code