Skip to content

Conversation

@dimitri-yatsenko
Copy link
Member

Summary

Remove unsigned integer types (uint8, uint16, uint32, uint64) from DataJoint's core type system for v2.0. These types are MySQL-specific and not portable to PostgreSQL and other database backends.

Motivation

DataJoint 2.0 is in pre-release and aims to support multiple database backends (PostgreSQL support coming in v2.1). Unsigned integer types only exist in MySQL, creating portability issues:

  • PostgreSQL: Must promote to larger signed types (e.g., uint16 would map to INTEGER)
  • Storage overhead: 2-4 extra bytes per value when promoted
  • Confusion: Unclear what types are truly portable

Since v2.0 already requires migration from 0.14.6, this is the ideal time to establish a clean, portable core type system.

Changes

Implementation (src/datajoint/declare.py)

  • REMOVED uint8, uint16, uint32, uint64 from CORE_TYPES dictionary
  • These types no longer exist as core DataJoint types
  • They are not passed through or supported

Tests (6 files updated)

Replaced all unsigned core types with signed equivalents:

  • uint8int16 (larger signed type for unsigned 8-bit range)
  • uint16int32 (larger signed type for unsigned 16-bit range)
  • uint32int64 (larger signed type for unsigned 32-bit range)

Files:

  • tests/schema_simple.py - E.M.id_m
  • tests/schema_type_aliases.py - Removed unsigned types from test table
  • tests/schema.py - Auto.id, Ephys.Channel.channel
  • tests/schema_university.py - Student.student_id, Course.course
  • tests/integration/test_type_aliases.py - Removed unsigned type test cases
  • tests/integration/test_hidden_job_metadata.py - All uint8 → int16

Note: test_blob.py and test_blob_matlab.py unchanged (testing numpy dtypes in serialization, not DataJoint table definitions).

Migration Path

OLD (0.14.6, no longer works in 2.0):

mouse_id : uint32   # ❌ Core type removed

NEW (2.0, portable):

mouse_id : int64    # ✅ Use larger signed core type

Alternative (MySQL-only, not portable):

mouse_id : int unsigned   # ⚠️ Native MySQL type (with warning)

Core Types After This Change

Signed integers only:

  • int8TINYINT
  • int16SMALLINT
  • int32INT
  • int64BIGINT

Unsigned removed:

  • uint8 ❌ REMOVED
  • uint16 ❌ REMOVED
  • uint32 ❌ REMOVED
  • uint64 ❌ REMOVED

Users who need unsigned integers must use native MySQL types like tinyint unsigned, int unsigned, etc., which will trigger warnings about non-portable types.

Impact

Who is affected:

  • Users migrating from 0.14.6 with schemas using uint8, uint16, uint32, uint64 core types
  • These types will cause errors (unknown type)

Migration:

  • Simple find-replace in schema definitions
  • No data migration needed (values remain compatible)
  • Example: mouse_id : uint32mouse_id : int64

Why this is acceptable:

  • ✅ v2.0 is pre-release - perfect time for breaking changes
  • ✅ Already requires migration from 0.14.6
  • ✅ Creates clean foundation for multi-database support (v2.1)
  • ✅ Easy migration path (find-replace in code)
  • ✅ No data migration required

Related

  • Part of v2.0 core type system revision
  • Establishes foundation for v2.1 PostgreSQL support (branch pre/v2.1)
  • See: PROPOSAL_CORE_TYPES_REVISION.md for full rationale

Testing

  • All existing tests updated to use signed types
  • Tests pass with new core type system
  • CI will validate on both Python versions and MySQL versions

Remove uint8, uint16, uint32, and uint64 from CORE_TYPES dictionary.
These unsigned integer types are MySQL-specific and not portable to
PostgreSQL and other database backends.

Unsigned types can still be used as native types (with existing
warning system for non-core types), but are no longer recommended
as part of DataJoint's portable core type system.

This establishes a clean foundation for multi-database support in v2.1.

Part of v2.0 core type system revision.
Replace all uses of uint8, uint16, uint32, uint64 with their signed
counterparts in test schemas, following the removal of unsigned types
from core types.

Changes:
- uint8 → int16 (larger signed type for unsigned 8-bit range)
- uint16 → int32 (larger signed type for unsigned 16-bit range)
- uint32 → int64 (larger signed type for unsigned 32-bit range)
- int unsigned → int64 (native type replacement)

Updated files:
- tests/schema_simple.py: E.M.id_m
- tests/schema_type_aliases.py: Remove unsigned types from test table
- tests/schema.py: Auto.id, Ephys.Channel.channel
- tests/schema_university.py: Student.student_id, Course.course
- tests/integration/test_type_aliases.py: Remove unsigned type tests
- tests/integration/test_hidden_job_metadata.py: All uint8 → int16

Note: test_blob.py and test_blob_matlab.py unchanged (testing numpy
dtypes in serialization, not DataJoint table definitions).

Part of v2.0 core type system revision.
@github-actions github-actions bot added enhancement Indicates new improvements feature Indicates new features labels Jan 17, 2026
- priority: uint8 → int8
- pid: uint32 → int32
- connection_id: uint64 → int64

Ensures job queue uses only core signed integer types.
- Tests that 'int unsigned', 'bigint unsigned', etc. are allowed
- Documents that these are MySQL-specific, not portable
- Users should prefer signed core types for compatibility

Also bump version to 2.0.0a22
@dimitri-yatsenko dimitri-yatsenko merged commit ac98154 into pre/v2.0 Jan 17, 2026
7 of 8 checks passed
@dimitri-yatsenko dimitri-yatsenko deleted the feature/remove-unsigned-core-types branch January 17, 2026 07:08
dimitri-yatsenko added a commit to datajoint/dj-zarr-codecs that referenced this pull request Jan 17, 2026
Update example table definitions to use int32 instead of uint16
to align with DataJoint 2.0.0a22 which removed unsigned integer
types from core types.

Changes:
- Recording.recording_id: uint16 → int32
- MyTable.id: uint16 → int32

Related: datajoint/datajoint-python#1335
dimitri-yatsenko added a commit to datajoint/dj-photon-codecs that referenced this pull request Jan 17, 2026
Update example table definitions to use int32 instead of uint16
to align with DataJoint 2.0.0a22 which removed unsigned integer
types from core types.

Changes:
- Recording.recording_id: uint16 → int32

Related: datajoint/datajoint-python#1335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Indicates new improvements feature Indicates new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants