Skip to content

feat: Allow string enums to be passed in for index find - #102

Open
Drache93 wants to merge 4 commits into
mainfrom
feat/indexable-string-enums
Open

feat: Allow string enums to be passed in for index find#102
Drache93 wants to merge 4 commits into
mainfrom
feat/indexable-string-enums

Conversation

@Drache93

@Drache93 Drache93 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Previously a string enum could only be searched via uint

@Drache93
Drache93 requested review from a team and mafintosh July 3, 2026 09:14
Drache93 and others added 4 commits August 4, 2026 11:24
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
Drache93 force-pushed the feat/indexable-string-enums branch from b6c934e to 0e7f24c Compare August 4, 2026 10:24
Comment thread builder/codegen.js
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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants