Skip to content

docs(postgres): document default TimeZone=UTC session behavior#4344

Open
jeremie0342 wants to merge 1 commit into
transact-rs:mainfrom
jeremie0342:docs/pg-timezone-note
Open

docs(postgres): document default TimeZone=UTC session behavior#4344
jeremie0342 wants to merge 1 commit into
transact-rs:mainfrom
jeremie0342:docs/pg-timezone-note

Conversation

@jeremie0342

Copy link
Copy Markdown

What

Adds a # Note: TimeZone section to the PgConnectOptions documentation
(sqlx-postgres/src/options/doc.md).

Why

When executing queries whose result depends on the session TimeZone
(e.g. date_trunc('day', ts) on a timestamptz), users can observe
different results between SQLx and psql against the same database.
This is expected: SQLx sets the session TimeZone to UTC on
connection, whereas psql inherits the server's default. This behavior
was previously undocumented on the user-facing API.

Scope

  • One file changed: sqlx-postgres/src/options/doc.md
  • Documentation only, no code change, no behavior change
  • Follows the existing # Note: X pattern used for other gotchas
    (SSL, Default Host, Unix Domain Sockets)
  • Reference-style links, consistent with the rest of the file

Closes #3226

Adds a "Note: TimeZone" section to PgConnectOptions documentation
explaining that SQLx sets the session TimeZone to UTC on connection,
why this is done, and how it differs from psql's default behavior
(which can surprise users of functions like date_trunc, now, etc.).

Closes transact-rs#3226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlx query's output is different when the same query is run from postgresql cli

1 participant