Fix jobs table generation for uuid FK-derived primary keys (#1515)#1518
Merged
Conversation
Job._generate_definition() emitted attr.type (the backend-resolved SQL type, e.g. binary(16) for a uuid attribute) into a fresh DataJoint definition string. That resolved type is not valid DataJoint definition syntax, so declaring the ~~jobs table raised 'Unsupported attribute type binary(16)' on the first .jobs access (including inside populate(reserve_jobs=True)), and never recovered. Use attr.original_type (the DataJoint-level alias, e.g. uuid) with a fallback to attr.type, mirroring the fallback DataJoint already uses in heading.py. This makes jobs-table generation correct for every core-type alias in an FK-derived primary key (uuid, float32, ...), not just uuid. Adds a regression test: a Computed table whose primary key is FK-derived from a uuid attribute.
MilagrosMarin
approved these changes
Jul 21, 2026
Contributor
There was a problem hiding this comment.
LGTM.
Small strengthening: the fix mirrors the same original_type or type fallback in TWO existing sites — heading.py:543 AND table.py:1327 (inside Table.describe). Worth mentioning the second precedent in the PR body — reinforces "jobs.py was the outlier missing the pattern" rather than "one-off similarity".
Optional hardening: test uses uuid only, but the fix generalizes to any core-type alias. A parameterized second case (e.g., decimal(6,3) PK) would catch a hypothetical mis-regression like if original_type == "uuid": ... else: attr.type. Non-blocking — the fix generalizes by construction (the or short-circuit applies to any attribute whose original_type is set).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1515.
Problem
Accessing
.jobson aComputed/Importedtable whose primary key is FK-derived from auuidattribute crashed with:This fires on the first
.jobsaccess for such a table — including the implicit access insidepopulate(reserve_jobs=True)— and never recovers, since the~~jobstable stays undeclared. It disablesreserve_jobs=Trueentirely for the common, recommended pattern of usinguuidroot keys with downstream computed tables.Root cause
Job._generate_definition()builds the~~jobstable's DataJoint definition string from the target's FK-derived primary key. For each attribute it emittedattr.type— the backend-resolved SQL type (binary(16)for auuid) — rather than the DataJoint-level alias the user wrote (uuid).binary(16)is not valid DataJoint definition syntax, so whenJob.declare()re-parsed the generated string,match_type("binary(16)")matched no pattern and raised.Fix
Use
attr.original_type or attr.typein_get_fk_derived_pk_attrs, mirroring the fallback DataJoint already uses inheading.py(original_type = attr["original_type"] or attr["type"]).original_typeholds the DataJoint alias for core types (uuid,float32, …) and isNoneotherwise, so:uuidPK → definition lineitem : uuid(re-parses correctly; DataJoint resolves it back tobinary(16)internally).uuid.attr.typeas before).Test
Adds
test_jobs_table_uuid_fk_derived_pk(plus aBasicComputedtable in the uuid test schema: aComputedtable whose PK is FK-derived from auuidparent). It asserts the generated definition carriesuuid(notbinary(16)), that.jobs.refresh()declares the table, and that the PK attribute round-trips tooriginal_type == "uuid".