Skip to content

Will TimestampTZ be removed in the future? #1694

Closed

Description

@FransBouma

This line: https://github.com/npgsql/npgsql/blob/dev/src/Npgsql/NpgsqlTypes/NpgsqlDbType.cs#L244

The enum value NpgsqlDbType.TimestampTZ is marked deprecated and instead users should use TimetampTz. That's fully understandable, however we map types with enum values as strings (so we don't have to take a direct reference on the ADO.NET provider, but can set the enum value in the DbParameter at runtime through IL generated setters). We used to map Timestamptz as 'Timestamp' but should use TimestampTZ/z. To fix that issue in our code we therefore have to pick a TimestampTZ/z variant: the one currently deprecated (but present in the npgsql dll on nuget) or the one with 'z', which is the name going forward. I can only pick one.

So the question is: will TimestampTZ ever be removed? If it's marked as 'deprecated' that's ok, the code isn't linked in the compiler anyway (only through DbProviderFactory and reflection). However if it's removed (because it's deprecated), then we have a problem.

I know it's hard to look into the future ;) but if you have a policy of never remove stuff anyway and only mark things deprecated going forward, we won't run into the issue where an enum value 'TimestampTZ' isn't present and it breaks at runtime.

TIA

Activity

  1. roji commented on Oct 27, 2017

    @roji
    Member

    Hey @FransBouma, nice to see you :)

    I didn't have any concrete plan to remove TimestampTZ (TimeTZ is the same), but there also isn't any sort of hard policy to never remove/break things... I admit that I would like to remove it them at some point, to keep the library clean going forward.

    In theory you could have two string options to try in your reflection, right? I'm sure it's not something you'd love to do, but is it a huge pain?

  2. roji commented on Oct 27, 2017

    @roji
    Member

    BTW, do you have some continuous integration testing LLBGen against Npgsql's dev branch or something? If so, is this the only issue you've noticed? It's nice to have external automatic validation of Npgsql's backwards compat...

  3. FransBouma commented on Oct 27, 2017

    @FransBouma
    ContributorAuthor

    hey @roji great to see you too! :) It's ok if it's in a few years from now and not the next version in say a few months, then it's fine by me. I understand you want to clean up stuff at some point, e.g. with v4. We could test for that version for example and switch types then.

    The problem is that we generate the type name in the code, so there's just room for one version. Our code simply reflects on the values in the enum and builds lookups for name-> enum value and a setter from IL to set the property on the NpgsqlParameter. So unfortunately we have just room for one value.

    If you don't remove it in the v3 lifetime it's ok and it would work out fine for us. If you remove it in v4 for instance, we can solve it then, that's not a problem.

    No CI here, sorry :) We only use integration tests but for specific things which differ per db as most code is generic. A customer ran into this (a local datetime wasn't converted to UTC, due to this). A typeconverter solved it but it's better if we solve the mapped type, and there we ran into this :)

  4. roji commented on Oct 27, 2017

    @roji
    Member

    OK, no problem.

    For now I'm not really following strict semver for Npgsql - I do introduce breakage, sometimes even somewhat substantial, in minor versions (e.g. 3.3). It's not very different from how PostgreSQL themselves versioned (major and minor were more or less the same) before the 10.0 release. So basically there won't be a version 4 until Npgsql receives a substantial rewrite or something, which I don't really plan in the near future. Basically don't worry about it, and I'll add a comment pointing to this issue in the code to avoid killing it by mistake.

  5. FransBouma commented on Oct 28, 2017

    @FransBouma
    ContributorAuthor

    @roji thanks man, I'll proceed and add the TimezoneTZ mapping and also add a note that it will change in the future :) Keep up the good work!

  6. roji commented on Nov 13, 2023

    @roji
    Member

    @FransBouma just doing some cleanup around obsoletions and noticed this - do you think it's OK for us to remove NpgsqlDbType.TimestampTZ and TimeTZ at this point (6 years later 😅)? One reason we want to do this is that it seems to break PowerShell (with the only difference in members being the casing...)

  7. FransBouma commented on Nov 13, 2023

    @FransBouma
    ContributorAuthor

    @FransBouma just doing some cleanup around obsoletions and noticed this - do you think it's OK for us to remove NpgsqlDbType.TimestampTZ and TimeTZ at this point (6 years later 😅)? One reason we want to do this is that it seems to break PowerShell (with the only difference in members being the casing...)

    It's fine with me, we switched to TimestampTz a while ago, so our code only uses TimestampTz and not TimestampTZ :) Vacuum away! :D

  8. roji commented on Nov 13, 2023

    @roji
    Member

    Thanks @FransBouma!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions