feat: Allow string enums to be passed in for index find - #102
Open
Drache93 wants to merge 4 commits into
Open
Conversation
Previously a string enum could only be searched via uint
Keeps previous behaviour where a string enum could also be searched by its uint value. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Enum types carry no hyperdb id, so the helpers were named by sanitizing the fqn. That collides (@db/a-b and @db/a_b both give enum_db_a_b, and the dedupe map was keyed on fqn so both would be emitted) and it reads unlike every other generated id, which is collection<id>/index<id>/helpers<id>. hyperschema already assigns every type a stable append-only position, so use it: enum<position>. Also collapses the two key-component-to-enum lookups into one resolver; they had drifted to different predicates. Generated output is unchanged apart from the identifier. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drache93
force-pushed
the
feat/indexable-string-enums
branch
from
August 4, 2026 10:24
b6c934e to
0e7f24c
Compare
mafintosh
reviewed
Aug 4, 2026
| for (let i = 0; i < enumType.enum.length; i++) { | ||
| str += ` case ${s(enumType.enum[i].key)}: return ${i + enumType.offset}\n` | ||
| } | ||
| str += ' default: return v\n' |
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.
Previously a string enum could only be searched via uint