Skip to content

PostgreSQL utc_now() needs to have specific UTC timezone #9

@yesthesoup

Description

@yesthesoup

default_sql_now returns CURRENT_TIMESTAMP for psql, but without specifying UTC this returns the server's local time.

SQLAlchemy docs recommend the following implementation for a psql utc_now():

@compiles(utcnow, 'postgresql')
def pg_utcnow(element, compiler, **kw):
    return "TIMEZONE('utc', CURRENT_TIMESTAMP)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions