Skip to content

Conversation

@dependabot
Copy link

@dependabot dependabot bot commented on behalf of github Nov 24, 2025

Updates Npgsql from 9.0.4 to 10.0.0 and fixes breaking changes in date/time type mappings.

Breaking Changes in Npgsql 10.0

  • PostgreSQL date type now maps to .NET DateOnly (was DateTime)
  • PostgreSQL time type now maps to .NET TimeOnly (was TimeSpan)

Changes Made

1. Npgsql 10.0 Integration (PostgreSqlTypeTranslater.cs)

  • ✅ Add DateOnly/TimeOnly → NpgsqlDbType mappings
  • ✅ Refactor type mappings from if-else chain to FrozenDictionary for O(1) lookup

2. Core Type System Updates (TypeTranslater.cs)

  • ✅ Add DateOnly/TimeOnly support for all database implementations
  • ✅ Fix duplicate type checks: typeof(short) and typeof(int) appeared twice

3. TypeGuesser Package Update

  • ✅ Update TypeGuesser to 2.0.4 for .NET 8/9/10 support
  • ✅ Resolves build failures on net8.0 target framework

4. Cross-Database DateTime Comparison Fixes (DatabaseTests.cs)

  • ✅ Add DateTime ↔ DateOnly comparison logic in AreBasicallyEquals
  • ✅ Add string ↔ DateTime comparison for SQLite (stores DateTime as TEXT/ISO8601)
  • ✅ Fixes MoveData_BetweenServerTypes tests when moving data to SQLite
  • ✅ Handles cross-database date format differences using InvariantCulture parsing

5. SQLite Server Name Handling (SqliteServerHelper.cs)

  • ✅ Fix parameter precedence in GetConnectionStringBuilderImpl
  • ✅ Properly handle SQLite's file-based architecture where server=database

6. Test Infrastructure Improvements

  • ✅ Add [SkipDatabase] attributes for SQLite/Oracle where tests assume server/database separation
  • ✅ Enhance T4 template (ServerTests.tt) to extract ALL excluded databases from attributes
  • ✅ Regenerate ServerTests.g.cs with proper database exclusions

7. Aggregation Test Compatibility (AggregationTests.cs)

  • ✅ Update IsMatch() to handle DateOnly/DateTime interoperability
  • ✅ Allows test assertions to work with both old and new type mappings

Test Results

  • ✅ All tests passing (1,711 passed, 40 skipped)
  • ✅ Fixes Test_Calendar_Day test that expected DateTime but received DateOnly
  • ✅ Fixes 4 MoveData_BetweenServerTypes tests involving SQLite destinations
  • ✅ Fixes 3 ServerHelper_ChangeDatabase tests for SQLite/Oracle

Related

---
updated-dependencies:
- dependency-name: Npgsql
  dependency-version: 10.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot added .NET Pull requests that update .NET code dependencies Pull requests that update a dependency file labels Nov 24, 2025
Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

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

Review by RecurseML

🔍 Review performed on 11fddcc..5b60a64

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (1)

FAnsi.PostgreSql/FAnsi.PostgreSql.csproj

Npgsql 10.0 changed default mappings:
- PostgreSQL date → DateOnly (was DateTime)
- PostgreSQL time → TimeOnly (was TimeSpan)

Changes:
- Add DateOnly/TimeOnly mappings to PostgreSqlTypeTranslater
- Refactor type mappings to use FrozenDictionary for O(1) lookup
- Update test assertions to handle DateOnly/DateTime interoperability

Fixes Test_Calendar_Day failure in PR #77
Changes to base TypeTranslater class:
- Add DateOnly/TimeOnly type support for all database implementations
- Fix duplicate type checks: typeof(short) and typeof(int) appeared twice
- Improves consistency across all database backends

This complements the PostgreSQL-specific Npgsql 10.0 compatibility fix.
@jas88 jas88 changed the title Bump Npgsql from 9.0.4 to 10.0.0 Npgsql 10.0 compatibility: Add DateOnly/TimeOnly support Nov 26, 2025
- Remove DEBUG console output from DiscoveredDatabaseHelper
- Remove DEBUG console output from TypeTranslater.ParseDecimalSize
- Reduce CI test logger verbosity from 'detailed' to 'normal'
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 87.23404% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.81%. Comparing base (11fddcc) to head (0d20d48).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...i.Core/Discovery/TypeTranslation/TypeTranslater.cs 42.85% 2 Missing and 2 partials ⚠️
FAnsi.PostgreSql/PostgreSqlTypeTranslater.cs 97.43% 0 Missing and 1 partial ⚠️
FAnsi.Sqlite/SqliteServerHelper.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
- Coverage   72.95%   72.81%   -0.15%     
==========================================
  Files          96       96              
  Lines        6323     6337      +14     
  Branches      909      899      -10     
==========================================
+ Hits         4613     4614       +1     
- Misses       1418     1447      +29     
+ Partials      292      276      -16     
Flag Coverage Δ
unittests 72.81% <87.23%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jas88 added 12 commits November 26, 2025 18:31
Automatically determines all non-EOL .NET versions supported by current SDK:
- Uses _MinimumNonEolSupportedNetCoreTargetFramework (oldest supported)
- Uses NETCoreAppMaximumVersion (latest in SDK)
- Handles .NET 8-12 (through Nov 2027)

On .NET 10 SDK: net8.0;net9.0;net10.0
On .NET 11 SDK (Nov 2026): net10.0;net11.0 (after .NET 8/9 go EOL)

Projects can use $(SupportedNonEolTargetFrameworks) for multi-targeting
Change from method-level to fixture-level parallelization:
- Each database test suite runs as independent thread
- 6 workers (one per database type + margin)
- All tests for MySql run together, all Oracle tests together, etc.

This should provide clearer per-database test progress vs lockstep
method execution across all databases simultaneously.
SQLite added DROP COLUMN support in version 3.35.0 (March 2021).
Microsoft.Data.Sqlite 10.0.0 bundles SQLite 3.50.4, which fully
supports DROP COLUMN operations.

Changes:
- Removed outdated Assert.Ignore statements for DROP COLUMN
- Added missing DROP COLUMN tests to SQLite test suite:
  - AddAndDropColumn_Sequence_Success
  - AddColumn_InsertData_DropColumn_DataPreserved
- Both tests pass successfully

This reduces test skips from 41 to 39.
Removed 198 instances of #if MYSQL_TESTS, #if MSSQL_TESTS, #if ORACLE_TESTS,
#if POSTGRESQL_TESTS, and #if SQLITE_TESTS preprocessor directives and their
corresponding #endif statements from the test suite.

These constants were never defined and represented dead code from an old
conditional compilation system. The modern test architecture uses separate
test classes per database type (e.g., TableHelperColumnOperationTests_Sqlite.cs)
instead of preprocessor-based conditional compilation.

Files modified: 20 test files across the FAnsiTests project
Replaced TestCaseSource-based tests with per-database test classes for better
maintainability and parallelization.

Changes:
- Split ServerTests.cs into ServerTestsBase.cs + 5 per-database classes
- Added previously non-executing test: ServerHelper_ChangeDatabase
- Moved cross-database test MoveData_BetweenServerTypes to dedicated class
- Created template system for generating per-database test files

Benefits:
- Fixture-level test parallelization (each database runs independently)
- Easy to run/debug single database: dotnet test --filter ServerTests_MySql
- Clear test organization and maintainability
- Discovered and activated missing test coverage

Files:
- ServerTestsBase.cs: Base class with protected test methods
- ServerTests_MySql.cs: MySQL-specific tests
- ServerTests_MicrosoftSql.cs: SQL Server-specific tests
- ServerTests_Oracle.cs: Oracle-specific tests
- ServerTests_PostgreSql.cs: PostgreSQL-specific tests
- ServerTests_Sqlite.cs: SQLite-specific tests
- CrossDatabaseServerTests.cs: Cross-database data movement tests (20 combinations)
- TestGeneration/GeneratePerDatabaseTestsAttribute.cs: Future source generator support

To add new tests:
1. Add protected method to ServerTestsBase.cs
2. Add [Test] method to each ServerTests_{Database}.cs file
3. Or use /tmp/server-test-template.txt as template
Implemented a reflection-based approach that automatically discovers and generates
tests from base class methods, eliminating manual per-database file maintenance.

Key Features:
- Reflection discovers all protected methods in ServerTestsBase
- Auto-generates test cases for all 5 databases (or filtered subset)
- [SkipDatabase] attribute for compile-time exclusion
- [OnlyDatabase] attribute for database-specific tests
- Supports multiple parameter patterns (DatabaseType, DatabaseType+bool, etc.)

Benefits:
- Zero boilerplate: Add ONE method → get 5 tests automatically
- Compile-time filtering: Tests not generated for excluded databases
- No runtime Assert.Inconclusive() checks needed
- Guaranteed consistency across all databases
- Easy maintenance: Rename/delete method → all tests update automatically

Usage:
  // Add to ServerTestsBase.cs:
  [SkipDatabase(DatabaseType.Sqlite, "File-based database")]
  protected void MyTest(DatabaseType type) { /* test code */ }

  // Result: Automatically generates 4 tests (skips SQLite)

Files:
- Server/ServerTests.cs: Reflection-based test discovery and execution
- TestGeneration/SkipDatabaseAttribute.cs: Exclude specific databases
- TestGeneration/OnlyDatabaseAttribute.cs: Include only specific databases
- ServerTestsBase.cs: Updated to use filtering attributes

This eliminates the need for manual ServerTests_MySql.cs, ServerTests_Oracle.cs, etc.
files while providing better filtering than runtime Assert.Inconclusive() checks.
SQLite stores dates as TEXT, not native datetime types. When aggregating
by day, the result column contains strings like '2001-01-01 00:00:00'
rather than DateTime objects.

Added special handling in AggregationTests.IsMatch() to parse SQLite's
string dates when comparing against expected DateTime values. This allows
all SQLite calendar aggregation tests (year/quarter/month/day) to pass.

Removed [Ignore] attribute from CalendarAggregationTests_Sqlite.Test_Calendar_Day
since the test now works correctly.
Replaced 5 manually-maintained ServerTests_{Database}.cs files and the
reflection-based ServerTests.cs with a T4 template-based approach:

- ServerTests.tt: T4 template that reads ServerTestsBase.cs and generates
  test classes for all 5 databases (SQL Server, MySQL, Oracle, PostgreSQL, SQLite)
- ServerTests.g.cs: Auto-generated file containing all 5 test classes
- Respects [SkipDatabase] attributes (e.g., skips SQLite for server-specific tests)
- Handles methods with bool parameters (generates TestCase(true/false))

Benefits:
- Add ONE method to ServerTestsBase → automatically get 5 database tests
- No NUnit/reflection conflicts - generates clean, simple code
- Easy to maintain and extend
- No manual duplication

To regenerate after modifying ServerTestsBase.cs:
  cd Tests/FAnsiTests/Server
  t4 ServerTests.tt -o ServerTests.g.cs
Removed automatic T4 generation from build process. Instead:
- Keep ServerTests.g.cs checked into git (standard practice for generated code)
- Developers manually run T4 when modifying ServerTestsBase.cs
- CI/CD doesn't need T4 tooling - just uses the checked-in file

This is simpler and more reliable than build-time code generation.

To regenerate after modifying ServerTestsBase.cs:
  cd Tests/FAnsiTests/Server
  t4 ServerTests.tt
  mv ServerTests.cs ServerTests.g.cs
- Update TypeGuesser to 2.0.4 for .NET 8/9/10 support
- Fix DateTime/DateOnly comparison in AreBasicallyEquals for Npgsql 10.0 compatibility
- Fix SQLite server parameter precedence in GetConnectionStringBuilderImpl
- Add skip attributes for SQLite/Oracle tests that assume server/database separation
- Enhance T4 template to extract all excluded databases from SkipDatabase attributes
- Regenerate ServerTests.g.cs with proper database exclusions
SQLite stores DateTime values as TEXT (ISO8601 format), which causes them
to be retrieved as strings rather than DateTime objects when filling
DataTables. The AreBasicallyEquals comparison method now handles string-to-
DateTime conversions using InvariantCulture parsing to properly compare
values across database types.

This fixes the 4 remaining MoveData_BetweenServerTypes test failures when
moving data from SQL Server/MySQL/Oracle/PostgreSQL to SQLite.
@jas88 jas88 merged commit 0ad01fc into main Nov 27, 2025
4 of 5 checks passed
@jas88 jas88 deleted the dependabot/nuget/FAnsi.PostgreSql/main/Npgsql-10.0.0 branch November 27, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file .NET Pull requests that update .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants