Skip to content

fix(heading): keep table_info in set_primary_key so a later rename quotes for the backend - #1643

Open
mayuriphad wants to merge 1 commit into
datajoint:masterfrom
mayuriphad:fix/u-proj-rename-quoting
Open

mayuriphad wants to merge 1 commit into
datajoint:masterfrom
mayuriphad:fix/u-proj-rename-quoting

Conversation

@mayuriphad

Copy link
Copy Markdown

Fixes #1638

Heading.set_primary_key built the new heading without table_info, so it lost the connection. When a projection then renamed an attribute of that heading, Heading.select had no adapter and fell back to backtick quoting. That is why (dj.U("b") & T).proj(c="b") compiled to SELECT DISTINCT `b` as "c" and failed on PostgreSQL. MySQL accepts backticks, so it hid the problem there.

set_primary_key now passes table_info=self.table_info, the same way select already hands it on to the heading it builds.

The new unit test in tests/unit/test_pk_rules.py gives a heading a PostgreSQL adapter, calls set_primary_key, then renames an attribute. On master the expression comes out as `b`. With the fix it is "b". tests/unit passes locally (458 passed). I did not run the integration suite because there is no Docker on this machine for the testcontainers.

…otes for the backend

Signed-off-by: mayuriphad <mayuriphad656@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 18, 2026 10:08

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks

2 participants