Repository navigation
fix(declare): reject constant defaults on primary-key attributes - #1759
Open
godara-alt wants to merge 3 commits into
Open
godara-alt wants to merge 3 commits into
godara-alt wants to merge 3 commits into
Conversation
…ajoint#1712) Permit generated CURRENT_TIMESTAMP defaults, preserve secondary defaults, and test declarations across MySQL and PostgreSQL adapters.
… test fixture Allow the platform-created singleton sentinel its fixed default without exposing that exception to user declarations. Remove a redundant constant key default from the university fixture, whose CSV supplies an explicit key. Add regression tests.
This branch has not been deployed
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.
Summary
Fixes #1712.
Reject constant defaults on user-defined primary-key attributes at declaration time, while preserving generated
CURRENT_TIMESTAMPdefaults and existing behavior for secondary attributes.Root Cause
The declaration compiler previously rejected nullable primary-key attributes but allowed constant defaults.
This permitted insertions without an explicitly supplied primary-key value, causing repeated insertions to reuse the same constant key.
Changes
Reject constant numeric and string defaults on primary-key attributes with a descriptive
DataJointError.Continue allowing generated
CURRENT_TIMESTAMPdefaults.Preserve the framework-generated
_singletonsentinel, restricting its exception to the internal declaration path.Remove the redundant
omega=0default from the university test schema, where the CSV already supplies the key explicitly.Add regression tests covering MySQL and PostgreSQL adapters, constant defaults, generated defaults, secondary attributes and singleton behavior.
Testing and Verification
Final commit:
b43425beb2c6ef0c94627708c1602bb96eec8fb5Verified using GitHub Actions on the fork:
Test | Result -- | -- Lint and formatting | Passed Linux unit tests | Passed Windows unit tests (Python 3.10, 3.14, 3.15) | Passed MySQL integration tests (6 configurations) | Passed Minimum dependency versions (Python 3.10) | PassedFinal result: All 12 checks passed, with zero failures and zero pending checks.
Scope
The changes are limited to:
src/datajoint/declare.pytests/schema_university.pytests/unit/test_primary_key_defaults.pyNo new dependencies were introduced and no tests were disabled.
The branch is up to date with upstream
master.Ready for review.