Skip to content

New data type to store only time with timezone #14211

Closed as not planned
Closed as not planned

Description

@oleksandr-petryk

Issue Creation Checklist

Feature Description

Is your feature request related to a problem? Please describe.

I need data type to store only time with timezone, but I did not find the data type

Describe the solution you'd like

The solution is to create new data type.

PostgreSQL data type to solve this problem here - time [ (p) ] with time zone

Why should this be in Sequelize

It's useful data type.

Additional context

Sequelize has data type TIME but is store TIME WITHOUT TIMEZONE

Feature Request Checklist

Is this feature dialect-specific?

  • No. This feature is relevant to Sequelize as a whole.
  • Yes. This feature only applies to the following dialect(s): postgres

Would you be willing to implement this feature by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Activity

  1. ephys commented on Mar 7, 2022

    @ephys
    Member

    According to the documentation I could find, only postgres supports TIME WITH TIME ZONE

    dialect supports time with time zone
    postgres yes - https://www.postgresql.org/docs/9.1/datatype-datetime.html
    mariadb no - https://mariadb.com/kb/en/time/
    mssql no - https://docs.microsoft.com/en-us/sql/t-sql/data-types/time-transact-sql?view=sql-server-ver15
    mysql no - https://dev.mysql.com/doc/refman/8.0/en/time.html
    sqlite no - https://www.sqlite.org/datatype3.html
    db2 no - https://www.ibm.com/docs/en/db2-for-zos/11?topic=columns-date-time-timestamp-data-types
    ibmi no - https://www.ibm.com/docs/en/i/7.3?topic=formats-time-data-type
    snowflake no - https://docs.snowflake.com/en/sql-reference/data-types-datetime.html#time

    The base TIME datatype is here: https://github.com/sequelize/sequelize/blob/main/src/data-types.js#L464

    This could be implemented the same way we implement DataTypes.INTEGER.UNSIGNED: by adding a static getter that sets a flag. e.g. DataTypes.TIME.ZONED

    Then postgres's datatype can extend the TIME class to make its toSql method return TIME WITH TIME ZONE if the flag is set.
    Other dialects should log a warning if the flag is set as they don't support it.
    Example of how to do that: https://github.com/sequelize/sequelize/blob/main/src/dialects/postgres/data-types.js#L295

    This is the more annoying part: Typings will need to be updated too - https://github.com/sequelize/sequelize/blob/main/src/data-types.d.ts#L327

    And of course, both typing tests & unit tests would need to be added

  2. added
    dialect: postgres
    type: feature
    on Mar 7, 2022
  3. oleksandr-petryk commented on Mar 7, 2022

    @oleksandr-petryk
    Author

    I need to add warning to each dialect that not support time with timezone ?

  4. ephys commented on Mar 7, 2022

    @ephys
    Member

    Unfortunately yes, thankfully there is only a handful of them right now

  5. oleksandr-petryk commented on Mar 7, 2022

    @oleksandr-petryk
    Author

    It's not a problem 😄

    It's just that I haven't worked with such large projects yet, all I did was up to 20000 lines of code.

  6. oleksandr-petryk commented on Mar 7, 2022

    @oleksandr-petryk
    Author
  7. ephys commented on Mar 7, 2022

    @ephys
    Member
  8. oleksandr-petryk commented on Mar 9, 2022

    @oleksandr-petryk
    Author

    How can I push changes? I created new branch from main, but when I try to push it, it returns an error:

    remote: Permission to sequelize/sequelize.git denied to Sasha-hk.
    
    fatal: unable to access 'https://github.com/sequelize/sequelize.git/': The requested URL returned error: 403

    Branch name: feature/time-zoned

  9. ephys commented on Mar 9, 2022

    @ephys
    Member

    You need to create a fork (only maintainers can create branches in this repository), then open a pull request. All changes (including ours) are done through pull requests :)

    Since I think you cloned this repository directly, here is what you can do:

    • Create a fork of this repository
    • No need to clone your fork, instead change the remote of your local repository:
      git remote remove origin
      git remote add origin https://github.com/Sasha-hk/sequelize.git (the same URL you would use to clone)
    • Push your changes, this time it should work
    • Send us a pull request
  10. ephys commented on Mar 18, 2024

    @ephys
    Member

    I forgot to close this issue. Please see reasons for closing here: #14213 (comment)

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

    dialect: postgrestype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions