Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/postgrest/src/postgrest/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from datetime import datetime
from typing import Final, cast

DEFAULT_POSTGREST_CLIENT_HEADERS = {
"Accept": "application/json",
"Content-Type": "application/json",
}

DEFAULT_POSTGREST_CLIENT_TIMEOUT = 120

# PostgreSQL recognizes this string as the current transaction timestamp. The
# cast lets generated update types accept it for datetime columns while keeping
# the value sent to PostgREST unchanged.
NOW: Final[datetime] = cast(datetime, "now()")
14 changes: 14 additions & 0 deletions src/postgrest/tests/test_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from datetime import datetime
from typing import TypedDict

from postgrest.constants import NOW


class GeneratedUpdate(TypedDict, total=False):
updated_at: datetime


def test_now_is_compatible_with_generated_datetime_fields() -> None:
payload = GeneratedUpdate(updated_at=NOW)

assert payload == {"updated_at": "now()"}