Skip to content

Expose default collation through the public initializers#174

Merged
msallin merged 1 commit into
masterfrom
fix/initializer-default-collation
Jun 16, 2026
Merged

Expose default collation through the public initializers#174
msallin merged 1 commit into
masterfrom
fix/initializer-default-collation

Conversation

@msallin

@msallin msallin commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

The README lists "default collation" as a supported feature: pass a Collation as a constructor parameter for an initializer. SqliteInitializerBase is fully wired for it (it accepts a Collation and feeds it into SqliteDatabaseCreator/SqliteSqlGenerator), but none of the three concrete initializers forwarded it, leaving DefaultCollation always null. The feature was therefore unreachable without subclassing the abstract base.

Changes

Added Collation-accepting constructor overloads that forward to base(modelBuilder, defaultCollation) on:

  • SqliteCreateDatabaseIfNotExists(modelBuilder, Collation) and (modelBuilder, bool, Collation)
  • SqliteDropCreateDatabaseAlways(modelBuilder, Collation)
  • SqliteDropCreateDatabaseWhenModelChanges(modelBuilder, Collation) and (modelBuilder, Type, Collation)

All existing constructors are preserved and now chain through the new ones.

Tests

Added InitializerDefaultCollationTest verifying each new overload forwards the collation to DefaultCollation, plus a null-default baseline. Full suite green (53 tests).

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c956f063-7f4d-4ba4-ba30-4d49c13c5cc9

📥 Commits

Reviewing files that changed from the base of the PR and between 43ac922 and f1449d9.

📒 Files selected for processing (4)
  • SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs

📝 Walkthrough

Walkthrough

Three SQLite code-first database initializer classes (SqliteCreateDatabaseIfNotExists, SqliteDropCreateDatabaseAlways, SqliteDropCreateDatabaseWhenModelChanges) gain new public constructor overloads accepting a Collation parameter, which is forwarded to the base initializer. Existing constructors are rewired to delegate through these new overloads. A new unit test class verifies the forwarding behavior across all overloads.

Changes

Default Collation Support for DB Initializers

Layer / File(s) Summary
Collation constructor overloads in all three initializers
SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs, SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs, SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs
Each initializer gains new public constructors accepting Collation defaultCollation. Existing single- and two-parameter constructors are rewired to chain with null, and the new terminal constructors pass defaultCollation to the base initializer. SqliteDropCreateDatabaseWhenModelChanges centralizes all paths through a shared (DbModelBuilder, Type, Collation) overload.
Unit tests for DefaultCollation forwarding
SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs
Adds InitializerDefaultCollationTest with six test methods covering each new overload and asserting that DefaultCollation matches the supplied value, and is null when no collation is provided.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A collation was missing, now it's been found,
Each constructor forwarding it safe and sound.
With null as default when nothing is passed,
The base gets the value, delivered at last.
Hops through the overloads, no detail ignored—
The bunny reviews, and the tests are adored! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title directly and accurately summarizes the main change: exposing the default collation feature through public initializers.
Description check ✅ Passed The pull request description is directly related to the changeset, providing clear context about the feature gap, the specific changes made, and test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/initializer-default-collation

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs`:
- Around line 1-4: The file is missing an import for the SQLite.CodeFirst
namespace. The code references types such as History (used in typeof(History)),
Collation, and CollationFunction.RTrim which are all defined in the
SQLite.CodeFirst namespace but are not currently imported. Add a new using
statement for SQLite.CodeFirst at the top of the file alongside the existing
using directives.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d6bd5754-ef01-4971-b17b-fdb53cf236d0

📥 Commits

Reviewing files that changed from the base of the PR and between 81f12d5 and 43ac922.

📒 Files selected for processing (4)
  • SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs
  • SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs

SqliteInitializerBase already accepts a default Collation and feeds it into
SQL generation, but none of the three concrete initializers forwarded it, so
the documented "default collation" feature was unreachable without
subclassing. Add constructor overloads that pass a Collation to the base class.
@msallin msallin force-pushed the fix/initializer-default-collation branch from 43ac922 to f1449d9 Compare June 16, 2026 04:18
@sonarqubecloud

Copy link
Copy Markdown

@msallin msallin merged commit 6c8e098 into master Jun 16, 2026
4 checks passed
@msallin msallin deleted the fix/initializer-default-collation branch June 16, 2026 04:21
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