Skip to content

Allow writing DateTime.MinValue to timestamptz even though it's Unspecified #4032

Description

@roji

In 6.0, we cleanly separated UTC DateTime from non-UTC DateTime, mapping the former to timestamptz and the latter to timestamp; trying to write a non-UTC timestamp to timestamptz now errors (#3947).

However, we may want to have an exception specifically for DateTime.MinValue/MaxValue, especially since DateTime.MinValue is also the default. For example, say you have an EF Core entity with a DateTime property:

class MyEntity
{
    public DateTime Timestamp { get; set; }
}

We now map DateTime to timestamptz by default, but default(DateTime) has Kind=Unspecified, so it's impossible to save this entity without first manually initializing the property to DateTime.SpecifyKind(default, DateTime.Utc). This is a problematic state of affairs.

Instead, we could specifically identify MinValue/MaxValue and send them as-is (without any conversions).

/cc @NinoFloris

Activity

  1. added this to the 6.0.0 milestone on Oct 10, 2021
  2. self-assigned this
    on Oct 10, 2021
  3. NinoFloris commented on Oct 10, 2021

    @NinoFloris
    Member

    That sounds good! Specifically supporting default(DateTime) seems fairly important.

  4. added a commit that references this issue on Oct 13, 2021
    7a1ae3f
  5. added a commit that references this issue on Oct 13, 2021
    dba60fb
  6. changed the title [-]Allow writing DateTime.Min/MaxValue to timestamptz even though they're unspecified[/-] [+]Allow writing DateTime.Min to timestamptz even though they're unspecified[/+] on Oct 15, 2021
  7. changed the title [-]Allow writing DateTime.Min to timestamptz even though they're unspecified[/-] [+]Allow writing DateTime.Min to timestamptz even though it's unspecified[/+] on Oct 15, 2021
  8. changed the title [-]Allow writing DateTime.Min to timestamptz even though it's unspecified[/-] [+]Allow writing DateTime.Min to timestamptz even though it's Unspecified[/+] on Oct 15, 2021
  9. changed the title [-]Allow writing DateTime.Min to timestamptz even though it's Unspecified[/-] [+]Allow writing DateTime.MinValue to timestamptz even though it's Unspecified[/+] on Oct 15, 2021
  10. added theissue type on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions