Skip to content

Conversation

@idseefeld
Copy link
Contributor

@idseefeld idseefeld commented Jan 6, 2026

Prerequisites

This PR is required for a PostgreSQL provider. The main issue is NPocos case sensitive configuration for PostgreSQL (It is not a PostgreSQL issue!)
Some other fixes address slightly different SQL statements or behaviour of PostgreSQL.
For this PR is mostly important, that all Unit and Integration test are successful.

For a complete check of these changes you could checkout https://github.com/idseefeld/Umbraco-CMS/tree/v173/postgreSqlProvider which is a complete PostgreSQL provider implementation with additional Unit tests and updated Integration tests (see: \tests\Umbraco.Tests.Integration\appsettings.Tests.json)

This PR solves issue #20453

Copilot AI review requested due to automatic review settings January 6, 2026 21:14
@github-actions
Copy link

github-actions bot commented Jan 6, 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 🤖 🙂

Copy link
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 PR addresses SQL syntax issues to support a PostgreSQL provider for Umbraco CMS. The main changes focus on case-sensitive column naming (PostgreSQL requirement via NPoco configuration), adding sequence support for databases that use sequences instead of identity columns, and improving SQL query consistency across different database providers.

Key changes include:

  • Standardizing column name references using constants instead of hard-coded strings to ensure consistent casing
  • Adding sequence support methods to SQL syntax providers (for PostgreSQL's sequence-based auto-increment)
  • Converting hard-coded SQL queries to use typed query builders with proper column name quoting
  • Fixing case-insensitive string comparisons in WHERE IN clauses for PostgreSQL compatibility

Reviewed changes

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

Show a summary per file
File Description
ContentTypeRepositorySqlClausesTest.cs Fixed column name casing in test expectations (Id → id, UniqueId → uniqueId)
NPocoSqlExtensionsTests.cs Updated test to expect LOWER() wrapper for case-insensitive string comparisons
DictionaryTranslationMapperTest.cs Fixed expected column name casing (UniqueId → uniqueId)
DatabaseCacheRepository.cs Replaced InsertOrUpdate with explicit FirstOrDefault/Insert/Update pattern for better compatibility
UserIdKeyResolver.cs Changed ExecuteScalar to FirstOrDefault for consistency
UmbracoDatabaseFactory.cs Made DbProviderFactory and CreateDatabaseInstance protected/virtual for extensibility
UmbracoDatabaseExtensions.cs Changed ExecuteScalar to FirstOrDefault for COUNT queries
SqlSyntaxProviderBase.cs Added GetNullExtension, SupportsSequences, and AlterSequences methods for PostgreSQL support
ISqlSyntaxProvider.cs Added interface definitions for new sequence and null extension methods
Multiple Repository files Replaced hard-coded column names with QuoteColumnName calls and DTO constants
Query.cs Added FixCompareCasing to wrap string comparisons in LOWER() for case-insensitive queries
NPocoSqlExtensions.cs Added LOWER() wrapping for string values in WhereIn clauses
Multiple DTO files Added PrimaryKeyName constants and replaced hard-coded column names
DatabaseSchemaCreator.cs Added sequence support after table creation with identity columns
DatabaseDataCreator.cs Major refactoring to use centralized Insert method with auto-increment detection
EntityService.cs Added default ordering by path for deterministic descendant results
Constants-DatabaseSchema.cs Added common primary key and column name constants
Multiple API Controller files Changed from nameof() to DTO column name constants for ordering
Comments suppressed due to low confidence (3)

src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs:2362

        if (!alwaysInsert && installDefaultDataSettings?.InstallData == InstallDefaultDataOption.None)

src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs:2367

        if (!alwaysInsert && installDefaultDataSettings?.InstallData == InstallDefaultDataOption.Values &&

src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs:2373

        if (!alwaysInsert && installDefaultDataSettings?.InstallData == InstallDefaultDataOption.ExceptValues &&

@idseefeld idseefeld marked this pull request as draft January 7, 2026 09:36
@idseefeld idseefeld changed the title Fix sql syntax issues Fix sql syntax issues #20453 Jan 7, 2026
@idseefeld idseefeld changed the title Fix sql syntax issues #20453 Fix sql syntax issues (closes #20453) Jan 7, 2026
@idseefeld idseefeld closed this Jan 7, 2026
@idseefeld idseefeld deleted the v173/20453-fix-more-sql-syntax-issues-squash branch January 7, 2026 17:25
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.

1 participant