Skip to content

NpgsqlDbType having both TimestampTZ and TimestampTz breaks PowerShell #4788

Closed

Description

@sigseg1v

Steps to reproduce

Run the following in a PowerShell prompt or script (with Npgsql.dll in the current directory):

Add-Type -Path .\Npgsql.dll
[NpgsqlTypes.NpgsqlDbType]::TimestampTz

The issue

Running the above results in the following error.

ExtendedTypeSystemException: The field or property: "TimestampTz" for type: "NpgsqlTypes.NpgsqlDbType" differs only in
letter casing from the field or property: "TimestampTZ". The type must be Common Language Specification (CLS)

It seems that it's not possible to call any functions that take a NpgsqlDbType parameter in PowerShell with value TimestampTz because of this. Simply referencing TimestampTz at all will throw the above error.

This appears to be because there are two possible values for the enum, TimestampTZ and TimeStampTz and powershell is case-insensitive (see: https://github.com/npgsql/npgsql/blob/main/src/Npgsql/NpgsqlTypes/NpgsqlDbType.cs#L229)

I understand that previously in #1694 there is already discussion around removing it. I don't necessarily expect you to add official support for PowerShell (personally, I don't even like using it, and I'll use this as a reason to use C# instead for the case where I ran into this). However, it would be good for anyone who searches up this error to know about this limitation, and I'll leave this here in case it affects your consideration to remove the TimestampTZ value in the future.

Further technical details

Npgsql version: 7.0.0
PostgreSQL version: N/A
Operating system: Windows 11, PowerShell 7.3.0

Activity

  1. roji commented on Dec 5, 2022

    @roji
    Member

    @griever989 isn't it enough that Powershell errors in the very explicit way you're showing above? I assume you're proposing a note somewhere in our docs calling this out - would that actually help people (am assuming very few would actually see it).

  2. added this to the Backlog milestone on Mar 9, 2023
  3. sigseg1v commented on Mar 10, 2023

    @sigseg1v
    Author

    My thought for this was one of two cases:

    A) npgsql team makes no changes, but just the existence of this github issue is self-documenting in that it would let people searching the issues/web find this very issue page and know that this is a known incompatibility and they should work around it on their own

    B) npgsql team decides to remove the TimestampTZ and TimeTZ types with the Obsolete attribute which then resolves this incompatibility

  4. roji commented on Mar 10, 2023

    @roji
    Member

    Is obsoletion enough to resolve this problem for Powershell?

  5. modified the milestones: Backlog, 8.0.0 on Nov 13, 2023
  6. self-assigned this
    on Nov 13, 2023
  7. added 2 commits that reference this issue on Nov 13, 2023
    25a82d4
    7db9abc
  8. added a commit that references this issue on Nov 13, 2023
    fdc0186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions