UNSET Sentinel
Import
Three Field States
Checking Field State
Field Definitions
to_input() Pattern
Common Patterns
UUID4 Auto-Generation
Creating New Objects
Checking if New
Save Workflow
Manual ID Update
Detection Logic
Combined Usage
Creating and Saving New Object
Partial Update
Explicit Null vs UNSET
Testing Patterns
Test UNSET
Test UUID4
Common Mistakes
❌ Wrong: Using == with UNSET
✅ Right: Using is with UNSET
❌ Wrong: Boolean check for UNSET
✅ Right: Explicit UNSET check
❌ Wrong: Manually setting UUID
✅ Right: Let it auto-generate
Type Annotations
For Fields
For Functions
Performance Notes
- UUID4 generation: ~0.1μs per object
- UNSET check: O(1) identity comparison
- Memory: UNSET is a singleton (minimal overhead)
Summary
Convenience Helper Methods
Some entity types provide convenience methods for relationship management.Scene Helpers (7 methods)
Tag Helpers (6 methods)
Entity Mapping Helpers
Convert entity names to IDs with auto-creation support:Studio Hierarchy Helpers
Notes
- Group convenience helpers are documented in Bidirectional Relationships but not yet implemented. Currently, manage group relationships using direct field assignment with
containing_groupsandsub_groupsfields. - Other entity types (Performer, Gallery, Image, etc.) do not have convenience helpers - use direct field assignment instead.
Additional Resources
- Full Guide: UNSET & UUID4 Patterns - Comprehensive guide with examples
- Usage Examples: Convenience Methods - ID mapping, hierarchy navigation
- Architecture: Bidirectional Relationships - Entity relationship patterns
- API Reference: StashEntityStore - Identity map and caching