Skip to content

PG date being returned as .NET DateOnly is a problematic breaking change #6349

@NaeemShah1990

Description

@NaeemShah1990

After upgrading to Npgsql v10, my application crashes with a date-parsing exception for PostgreSQL DATE columns that contain values formatted as dd/MM/yyyy.
The same code works perfectly in Npgsql v9, so this appears to be a regression introduced in v10 (released today).

📌 Environment

Npgsql Version: 10.x (latest)
Previous Working Version: 9.x
.NET: .NET 10
Application Type: C# WinForms application using Dapper ORM
OS: Windows 11
Database: PostgreSQL 17

Exception

System.Data.DataException: Error parsing column 31 (expirydate=24/11/2025 - DateOnly)

🔎 What Happened

Our PostgreSQL table contains a DATE field (expirydate) which stores values in dd/MM/yyyy format, for example:
24/11/2025

This maps to a normal C# property:
public DateTime? ExpiryDate { get; set; }

In Npgsql v9, this works perfectly.
In Npgsql v10, the same code throws an exception.
No breaking change related to date formats is documented.
This indicates a regression in the new v10 release.

Expected Behavior

Npgsql should continue supporting PostgreSQL’s valid date formats (including dd/MM/yyyy when DateStyle is configured accordingly).
Parsing rules should match v9’s behavior unless intentionally changed and documented.

🚫 Actual Behavior

Npgsql v10 now attempts strict parsing into DateOnly.
It rejects dd/MM/yyyy even though PostgreSQL stores it.
A fatal exception is thrown during data mapping.
This did not happen in any previous version.

🧪 Minimal Repro Code

var products = connection.Query<Product>(
    @"SELECT expirydate FROM products WHERE productid = 1"
).ToList();

Model

public class Product
{
    public DateTime? ExpiryDate { get; set; }
}

Value in PostgreSQL
24/11/2025

Results
v10 → exception
v9 → works normally

📝 Notes

Npgsql v10 was released only a few hours ago — this may be an early regression.
If strict DateOnly parsing was intentional, it is not documented.
Many production PostgreSQL systems store non-ISO date formats, so this breaks real-world applications.

📣 Request

Please confirm:
Is this a bug or intended behavior?
If intended, can we get a compatibility option to keep v9 date-parsing behavior?
If a bug, please fix in the next patch release (10.0.x).

Thank you!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions