Skip to content

Fix 0762b3c7694d datetime migration on non-empty tables - #40

Merged
axf295 merged 1 commit into
mainfrom
fix/datetime-migration-row-indexing
Sep 9, 2026
Merged

Fix 0762b3c7694d datetime migration on non-empty tables#40
axf295 merged 1 commit into
mainfrom
fix/datetime-migration-row-indexing

Conversation

@axf295

@axf295 axf295 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Ran into a problem trying ot convert a mapcat at site that Carlos made for depth1 testing.

Claude found the following:

Two bugs in the row-conversion loops (unix_to_datetime/datetime_to_unix) that only manifest once a table has at least one row, so an empty-database migration test never exercises them:

  • row[column_name] used string-key indexing on a SQLAlchemy Core Row, which SQLAlchemy 2.0 no longer supports (positional-only); switch to row._mapping[column_name].
  • cur_table was reflected once before the per-column temp_* column was added via op.add_column, so the later cur_table.update().values({...}) didn't recognize that column ("Unconsumed column names"); re-reflect cur_table after each op.add_column.

Verified against a database with existing rows: reproduces both failures on the original code and succeeds after the fix.

Claude-Session: https://claude.ai/code/session_01Rh1TMcQhLGM8TyQZ947Rvt

Two bugs in the row-conversion loops (unix_to_datetime/datetime_to_unix)
that only manifest once a table has at least one row, so an empty-database
migration test never exercises them:

- row[column_name] used string-key indexing on a SQLAlchemy Core Row,
  which SQLAlchemy 2.0 no longer supports (positional-only); switch to
  row._mapping[column_name].
- cur_table was reflected once before the per-column temp_* column was
  added via op.add_column, so the later cur_table.update().values({...})
  didn't recognize that column ("Unconsumed column names"); re-reflect
  cur_table after each op.add_column.

Verified against a database with existing rows: reproduces both failures
on the original code and succeeds after the fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rh1TMcQhLGM8TyQZ947Rvt
@axf295
axf295 requested a review from Sulla2012 September 8, 2026 19:53

@Sulla2012 Sulla2012 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Sorry I didn't catch this before.

@Sulla2012

Copy link
Copy Markdown
Contributor

Can't merge due to 3.12 tests failing.

@axf295

axf295 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Can't merge due to 3.12 tests failing.

yea I noticed that - but it's just the nersc side of things failing to download the test files I think... not sure what to do about that.

@Sulla2012

Copy link
Copy Markdown
Contributor

Rerunning the test is the simplest way.

@axf295
axf295 merged commit bad5219 into main Sep 9, 2026
6 of 7 checks passed
@axf295
axf295 deleted the fix/datetime-migration-row-indexing branch September 9, 2026 18:25
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