Skip to content

fix(sessions): Port PostgreSQL binary event actions migration fix to v1 - #6870

Open
shoemoney wants to merge 1 commit into
google:v1from
shoemoney:fix/v1-migration-memoryview
Open

fix(sessions): Port PostgreSQL binary event actions migration fix to v1#6870
shoemoney wants to merge 1 commit into
google:v1from
shoemoney:fix/v1-migration-memoryview

Conversation

@shoemoney

@shoemoney shoemoney commented Aug 23, 2026

Copy link
Copy Markdown

Link to Issue or Description of Change

Description: Ports the PostgreSQL binary event actions migration fix from main to the v1 branch (commit e3ae4ac).

Problem:
_row_to_event reads v0 event rows with raw SQL, so SQLAlchemy has no column type to coerce with and the driver's own binary representation reaches the migration code untouched. psycopg2 returns BYTEA columns as memoryview rather than bytes. The existing isinstance(actions_val, bytes) check failed for memoryview, falling through to the "backend returned an object" path, which silently replaced migrated event actions with an empty EventActions while reporting success.

Solution:
Extended the binary type check to accept bytes, bytearray, and memoryview, with explicit coercion to bytes() before unpickling. The Spanner object path is unchanged. Added a parametrized regression test covering all three binary types.

Testing Plan

Unit Tests:

  • Added parametrized regression test test_migrate_from_sqlalchemy_pickle_reads_every_binary_column_type covering bytes, bytearray, and memoryview.
  • All unit tests pass locally: tests/unittests/sessions/migration/test_migration.py, 36 passed.

Manual End-to-End (E2E) Tests:
On v1, unfixed code fails for the memoryview and bytearray cases with actions == {}; fixed code passes all parametrized variants.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.

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.

2 participants