Skip to content

Keep DateTime instants in pg timestamp params and Timeout::Error on Ruby 3.1's bundled timeout - #61

Merged
devin-ai-integration[bot] merged 1 commit into
mainfrom
devin/1793771294-pg-datetime-timeout
Nov 4, 2026
Merged

devin-ai-integration[bot] merged 1 commit into
mainfrom
devin/1793771294-pg-datetime-timeout

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three PostgreSQL-related fixes from a pre-release check.

  • DateTime parameters lost their time (PostgreSQL): the pg gem encodes a DateTime as a Date, so DateTime.new(2024, 1, 1, 10, 0, 0, '+02:00') was stored as midnight in timestamp / timestamptz columns. encode_timestamp now converts a DateTime to a local Time, the same way it already handles Time (this matches MySQL). The encoder now also runs for timestamptz params. The RBS still declares ::Time, the type rows return, same as on MySQL. Date params are unchanged: they mean midnight.
  • Timeout in a transaction raised the wrong error (Ruby < 3.3 with timeout < 0.4, e.g. Ruby 3.1's bundled 0.2.0): the old Timeout leaves the block with throw. The cancelled query left the transaction in error, and its ensure replaced the throw with PG::InFailedSqlTransaction. The legacy transaction template now skips that raise when the block was left without completing under an old Timeout. The transaction still rolls back and Timeout::Error reaches the caller. This also works for nested transactions (savepoints).
  • README note on the repeated DST hour: PostgreSQL timestamp and MySQL DATETIME store local wall-clock time. An instant in the hour that repeats when clocks fall back from daylight saving time reads back as the first of the two.

Tests

  • Both new tests fail on main and pass on this branch: test_datetime_parameters_keep_their_instant, and test_transaction_timeout_rolls_back_and_keeps_connection_usable (now with a nested-transaction case), both in tests/end2end_pg.rb.
  • CI: a new PostgreSQL E2E variant bundled-timeout on Ruby 3.1. Gemfile.e2e honours E2E_TIMEOUT_GEM=0.2.0 by replacing the generated gem 'timeout', '>= 0.4'. Until now every Ruby 3.1 job ran with timeout >= 0.4, so this path was never exercised.
  • Local run on Ruby 3.1 with timeout 0.2.0: 3 failures on main, 0 on this branch (93 runs). Ruby 3.4: 93 runs, 0 failures.
  • docs/Coverage.md and docs/Testing.md are updated. examples/pg and the pg golden files are regenerated, and steep_expectations.yml is updated for shifted line numbers (still 71 diagnostics).

Checklist

  • examples/ is regenerated (rake sqlc_generate_process) and committed
  • Tests added or updated (rake test, and rake end2end_* when the generated code changes)
  • The generated code stays RuboCop-clean (rake rubocop) and Steep-clean (rake steep)
  • Labelled (bug, enhancement, documentation, or breaking) so the release notes are grouped correctly

Requested by: @doron050

…uby 3.1's bundled timeout

Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the bug Something isn't working label Nov 4, 2026
@devin-ai-integration
devin-ai-integration Bot merged commit 77de005 into main Nov 4, 2026
42 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1793771294-pg-datetime-timeout branch November 4, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant