Allow empty insert for tables with all defaults (#1280)#1306
Merged
dimitri-yatsenko merged 4 commits intodocs-2.0-migrationfrom Jan 7, 2026
Merged
Allow empty insert for tables with all defaults (#1280)#1306dimitri-yatsenko merged 4 commits intodocs-2.0-migrationfrom
dimitri-yatsenko merged 4 commits intodocs-2.0-migrationfrom
Conversation
- When all attributes have defaults (autoincrement, nullable, or explicit
default), allow inserting empty dicts: table.insert1({})
- Generates SQL: INSERT INTO table () VALUES ()
- For tables with required fields, raise clear error listing which
attributes need values
- Add tests for empty insert scenarios
Closes #1280
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
All required codec methods (get_dtype, encode, decode) now use @AbstractMethod to catch missing implementations at class definition time rather than runtime. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
table.insert1({})INSERT INTO table () VALUES ()Changes
src/datajoint/table.py:
__make_row_to_insert(): Check if empty insert is allowed based on attribute defaults_insert_rows(): Handle empty field_list case for SQL generationtests/integration/test_insert.py:
TestEmptyInserttest class with:test_empty_insert_all_defaults: Verify empty insert works for all-defaults tabletest_empty_insert_multiple: Verify multiple empty inserts worktest_empty_insert_required_fields_error: Verify clear error for tables with required fieldsExample
Test Plan
Closes #1280
🤖 Generated with Claude Code