Skip to content

Management API: Replace nameof() by constants of DTO (closes #21303)#21344

Merged
AndyButland merged 52 commits intoumbraco:mainfrom
idseefeld:v173/20453-21303-nameof-in-raw-SQL
Jan 16, 2026
Merged

Management API: Replace nameof() by constants of DTO (closes #21303)#21344
AndyButland merged 52 commits intoumbraco:mainfrom
idseefeld:v173/20453-21303-nameof-in-raw-SQL

Conversation

@idseefeld
Copy link
Copy Markdown
Contributor

Prerequisites

Replace nameof(DTO.COLUMN_NAME) by constant of the DTO, because it leads to casing issues for case sensitive databases like PostgreSQL (NPoco implementation only!).

This is another part of issue #20453 and can only be merged after PR #21327

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 8, 2026

Hi there @idseefeld, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team 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:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

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 🤖 🙂

@idseefeld idseefeld marked this pull request as ready for review January 9, 2026 17:39
Copilot AI review requested due to automatic review settings January 9, 2026 17:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses PostgreSQL case sensitivity issues by replacing hard-coded string column names in NPoco DTO attributes with constants. This is part of addressing issue #20453 regarding SQL syntax issues for case-sensitive databases.

Key Changes

  • Introduced a new Constants.DatabaseSchema.Columns class containing common database column name constants (PrimaryKeyNameId, PrimaryKeyNamePk, PrimaryKeyNameKey, NodeIdName, UniqueIdName)
  • Updated 60+ DTO classes to replace hard-coded strings in NPoco attributes ([PrimaryKey], [Column], [ForeignKey], [Index], [PrimaryKeyColumn], [Reference]) with constant references
  • Updated API Management controller classes to use DTO constants instead of nameof() for ordering specifications
  • Fixed TableNamePrefix reference in UmbracoDbContext.cs to use the relocated constant

Reviewed changes

Copilot reviewed 76 out of 76 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Constants-DatabaseSchema.cs Added new Columns nested class with common column name constants; moved TableNamePrefix into Tables class
60+ DTO files Replaced hard-coded column name strings with constant references in NPoco attributes
UmbracoDbContext.cs Updated TableNamePrefix reference to use relocated constant path
FolderTreeControllerBase.cs Replaced nameof() with NodeDto constants for ordering
EntityTreeControllerBase.cs Replaced nameof() with NodeDto constants for ordering
RecycleBinControllerBase.cs Replaced nameof() with NodeDto constants for ordering
MediaTreeControllerBase.cs Replaced nameof() with NodeDto constants for ordering
DocumentBlueprintTreeControllerBase.cs Replaced nameof() with NodeDto constants for ordering
DocumentTreeControllerBase.cs Replaced nameof() with NodeDto constants for ordering
DataTypeTreeControllerBase.cs Replaced nameof() with NodeDto constants for ordering

internal sealed class PropertyTypeReadOnlyDto
{
public const string TableName = Constants.DatabaseSchema.Tables.PropertyType;
public const string PrimaryKeyName = "PropertyTypeId"; // there is an inconsistency in main branch between atributtes
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Spelling error in comment: "atributtes" should be "attributes"

Copilot uses AI. Check for mistakes.
internal sealed class PropertyTypeGroupReadOnlyDto
{
public const string TableName = Constants.DatabaseSchema.Tables.PropertyTypeGroup;
public const string PrimaryKeyName = "PropertyTypeGroupId"; // there is an inconsistency in main branch between atributtes
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Spelling error in comment: "atributtes" should be "attributes"

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +15
// ToDo: Here we have an incosistent column name in DatabaseSchema. It should be Constants.DatabaseSchema.Columns.PrimaryKeyNameId; ("id")
// For now we leave the databse schema as is to avoid breaking changes.
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Spelling error in comment: "incosistent" should be "inconsistent"

Suggested change
// ToDo: Here we have an incosistent column name in DatabaseSchema. It should be Constants.DatabaseSchema.Columns.PrimaryKeyNameId; ("id")
// For now we leave the databse schema as is to avoid breaking changes.
// ToDo: Here we have an inconsistent column name in DatabaseSchema. It should be Constants.DatabaseSchema.Columns.PrimaryKeyNameId; ("id")
// For now we leave the database schema as is to avoid breaking changes.

Copilot uses AI. Check for mistakes.
[ForeignKey(typeof(ContentTypeDto), Name = "FK_cmsContentTypeAllowedContentType_cmsContentType", Column = "nodeId")]
[PrimaryKeyColumn(AutoIncrement = false, Clustered = true, Name = "PK_cmsContentTypeAllowedContentType", OnColumns = "Id, AllowedId")]
// ToDo: Here we have an incosistent column name in DatabaseSchema. It should be Constants.DatabaseSchema.Columns.PrimaryKeyNameId; ("id")
// For now we leave the databse schema as is to avoid breaking changes.
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Spelling error in comment: "databse" should be "database"

Suggested change
// For now we leave the databse schema as is to avoid breaking changes.
// For now we leave the database schema as is to avoid breaking changes.

Copilot uses AI. Check for mistakes.
@idseefeld idseefeld marked this pull request as draft January 9, 2026 19:49
…utes again, because some integration tests for PostgreSQL provider fail without them. Again a case sensitivty issue.
make all column name const consistent
@idseefeld idseefeld marked this pull request as ready for review January 15, 2026 14:38
Copy link
Copy Markdown
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

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

This PR reveals a minor architectural concern, in that the API Management layer controllers directly reference Infrastructure.Persistence.Dtos constants. This couples the presentation layer to the data access layer. However that's not introduced in this PR - it already existed from the nameof property names.

So ideally we would abstract that at the service layer rather than exposing the column names to controllers.

As I say though, that's not made better or worse by this PR, so just noting in passing. Approving and merging, thanks @idseefeld.

@AndyButland AndyButland merged commit f36947a into umbraco:main Jan 16, 2026
26 checks passed
@AndyButland AndyButland changed the title Replace nameof() by constants of DTO (closes #21303) Management API: Replace nameof() by constants of DTO (closes #21303) Jan 16, 2026
@idseefeld idseefeld deleted the v173/20453-21303-nameof-in-raw-SQL branch January 16, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants