setUTCTimeZone pins the session TimeZone to UTC for every connection in the pool. Our created_at/updated_at columns are TIMESTAMP (without time zone). Postgres converts NOW()/CURRENT_TIMESTAMP (timestamptz) into the session's local wall clock when inserting into such columns, while pgx reads them ba
(poolCfg *pgxpool.Config)
| 189 | // Forcing the session to UTC keeps store and read consistent so relative-time |
| 190 | // formatting on the frontend doesn't drift by the DB host's TZ offset. |
| 191 | func setUTCTimeZone(poolCfg *pgxpool.Config) { |
| 192 | if poolCfg == nil || poolCfg.ConnConfig == nil { |
| 193 | return |
| 194 | } |
| 195 | if poolCfg.ConnConfig.RuntimeParams == nil { |
| 196 | poolCfg.ConnConfig.RuntimeParams = map[string]string{} |
| 197 | } |
| 198 | poolCfg.ConnConfig.RuntimeParams["TimeZone"] = "UTC" |
| 199 | } |
no outgoing calls
no test coverage detected