Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Preserve hidden row IDs when a column shadows rowid - #1000

Open
Divuzki wants to merge 1 commit into
simonw:mainfrom
Divuzki:preserve-shadowed-rowids
Open

Divuzki wants to merge 1 commit into
simonw:mainfrom
Divuzki:preserve-shadowed-rowids

Conversation

@Divuzki

@Divuzki Divuzki commented Dec 5, 2026

Copy link
Copy Markdown

Closes #999.

A table can have a text column called rowid and still expose its integer row ID through _rowid_ or oid. During a transform, the copy now picks an available alias from each schema independently. This preserves the hidden ID even when a rename changes which alias is available.

The regression tests start with row ID 42 and two declared columns that shadow aliases. One renames an unrelated column. The other renames RowID to oid. Before the fix the first row was renumbered to 1 and the second transform raised a datatype mismatch. Both tests check the hidden ID and all three stored values.

Windows, Python 3.14.7: 1,631 tests passed, 19 skipped.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T01:29:16.145562Z 0fdd9d1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fdd9d105c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sqlite_utils/db.py
(
alias
for alias in ("rowid", "_rowid_", "oid")
if alias not in declared

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve declared INTEGER PRIMARY KEY row-ID aliases

When a table declares rowid INTEGER PRIMARY KEY alongside _rowid_ TEXT and oid TEXT, rowid still aliases the actual integer row ID, but this helper treats all three names as shadowed and returns None. Starting with a single row whose ID is 42, transform(drop={'rowid'}, pk=None) consequently skips the hidden-ID copy and silently renumbers that row to 1; the parent commit preserved 42. Allow an integer-primary-key alias to supply source row IDs even when every magic alias is declared.

Useful? React with 👍 / 👎.

Comment thread sqlite_utils/db.py
None,
)

source_rowid = rowid_alias(existing_columns)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip hidden row-ID copying for WITHOUT ROWID sources

For a populated CREATE TABLE nodes (rowid TEXT PRIMARY KEY, name TEXT) WITHOUT ROWID, transform(rename={'name': 'label'}) succeeded before this change but now raises IntegrityError: datatype mismatch. The helper selects _rowid_ merely because it is undeclared, although this source has no hidden row ID. With SQLite's default double-quoted-string behavior, the generated SELECT "_rowid_" produces a string literal that cannot be inserted into the destination's hidden integer ID. Check whether the source actually has a row ID before adding this copy expression.

Useful? React with 👍 / 👎.

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.

Table.transform() renumbers rows when a declared column shadows rowid

1 participant