Shreemanarjun / Shreemanarjun/datum
Duplicate `snake_case` conversion in generator `fromMap` causes incorrect map keys
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 27
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
I noticed that _getMapKey() already converts field names to snake_case when no annotation is provided:
https://github.com/Shreemanarjun/datum/blob/5a122565cee19c50c928eb7717f2762fc7b109ae/packages/datum_generator/lib/src/datum_generator.dart#L800-L810
However, fromMap appears to apply _camelToSnake again when accessing the map value.
This results in a double conversion. For example:
// Dart field:
createdAt
_getMapKey() → created_at
But if _camelToSnake is applied again:
created_at → created__at
This can lead to incorrect map lookups or duplicate snake_case keys.
Expected behavior:
_getMapKey() should be the single source of truth for map keys.
Suggested fix:
fromMap should directly use the key returned by _getMapKey() without applying _camelToSnake again.
This keeps the mapping logic centralized and avoids accidental double conversions.
If this approach makes sense, I’d be happy to submit a PR for it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/datum_generator/lib/src/datum_generator.dart at the cited _getMapKey() lines, then inspect the fromMap lookup and its use of _camelToSnake. Confirm that _getMapKey() already returns the intended map key and that completion means fromMap uses that key without double conversion, preserving the expected created_at lookup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100