-
-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
The RestApiHandler's external_id_mapping configuration incorrectly parses single-field unique indexes that contain underscores in their field names, treating them as compound IDs instead.
Current Behavior:
When using external_id_mapping with a single field name containing underscores:
external_id_mapping: {
MyModel: 'external_unique_id'
}
Error:
The handler splits 'external_unique_id' by underscores into ['external', 'unique', 'id'] and attempts to find fields with those names, failing when they don't exist as separate fields.
Expected Behavior
external_id_mapping should support:
- Single-field unique indexes: { MyModel: 'external_unique_id' } where external_unique_id is one field
- Compound unique indexes: { MyModel: 'field1_field2' } where field1 and field2 are separate fields
Fixes
I see two possible fixes:
- Check if a field exists before splitting
- Optionally allow passing in an array of field names
For 1) it is a bit iffy, since this only really fixes the issue for non-compound columns. But since in theory the issue could also affect compound indexes, 2) would be cleaner.
Metadata
Metadata
Assignees
Labels
No labels