Skip to content

Commit 14ac950

Browse files
committed
fix(spec)!: Field.select shorthand keeps every character it does not document transforming, so a hyphenated option is refused rather than rewritten
sys_metadata_audit.lock_state becomes a text column holding the MetadataLock spelling its writer stores. Claude-Session: https://claude.ai/code/session_0123qkvzKLQfRRRnuR8wanHJ Co-authored-by: Claude <noreply@anthropic.com>
1 parent ae58b26 commit 14ac950

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

‎packages/metadata-core/src/objects/sys-metadata-audit.object.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,16 @@ export const SysMetadataAuditObject = ObjectSchema.create({
186186
* item carried no `_lock`). Captured even on `allowed` rows so
187187
* later compliance queries can see "what was the lock state when
188188
* this write succeeded".
189+
*
190+
* A text column, not a select: the writer stores the `MetadataLock`
191+
* spelling as is (`none` | `no-overlay` | `no-delete` | `full`), and a
192+
* select option value is a system identifier, which holds no hyphen. The
193+
* `Field.select([...])` shorthand used to strip the hyphen, declaring
194+
* `nooverlay` / `nodelete` — values no row ever held (#25013). Like `code`
195+
* above, the closed set lives with its writer (`MetadataLockSchema`).
196+
* No `maxLength`: existing columns keep their width and report no drift.
189197
*/
190-
lock_state: Field.select(['none', 'no-overlay', 'no-delete', 'full'], {
198+
lock_state: Field.text({
191199
label: 'Lock State',
192200
required: false,
193201
readonly: true,

‎packages/spec/src/data/field.zod.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,13 +3050,12 @@ type UserFieldInput = Omit<FieldInput, 'reference'> & {
30503050

30513051
/** `Field.select` with inline options — the array or `{ options }` forms. */
30523052
function selectWithOptions(optionsOrConfig: Array<SelectOption | string> | Omit<FieldInput, 'options'> & { options: Array<SelectOption | string> }, config?: FieldInput) {
3053-
// Helper function to convert string to lowercase snake_case
3054-
const toSnakeCase = (str: string): string => {
3055-
return str
3056-
.toLowerCase()
3057-
.replace(/\s+/g, '_') // Replace spaces with underscores
3058-
.replace(/[^a-z0-9_]/g, ''); // Remove invalid characters (keeping underscores only)
3059-
};
3053+
// The shorthand's whole transform: lower-case, and whitespace runs → `_`.
3054+
// Every other character stays as written, so a string that is no system
3055+
// identifier (`'no-overlay'`, `'v2-beta'`) reaches `SelectOptionSchema.value`
3056+
// and is refused there, by the same rule an explicit `{ value: 'no-overlay' }`
3057+
// meets — never rewritten into a value the author did not write (#25013).
3058+
const toSnakeCase = (str: string): string => str.toLowerCase().replace(/\s+/g, '_');
30603059

30613060
// Support both old and new signatures:
30623061
// Old: Field.select(['a', 'b'], { label: 'X' })
@@ -3163,6 +3162,12 @@ export const Field = {
31633162
* Field.select(['In Progress', 'Closed Won'], { label: 'Status' })
31643163
* // Results in: [{ label: 'In Progress', value: 'in_progress' }, { label: 'Closed Won', value: 'closed_won' }]
31653164
*
3165+
* Lower-casing and whitespace → `_` are the shorthand's only transforms; any
3166+
* other character is kept, so `Field.select(['no-overlay'])` yields the value
3167+
* `no-overlay`, which `SelectOptionSchema.value` refuses (a system identifier
3168+
* holds letters, digits, `_` and `.`). Write such an option explicitly:
3169+
* `{ label: 'no-overlay', value: 'no_overlay' }`.
3170+
*
31663171
* @example Shared picklist — the options come from the named `picklist` item
31673172
* Field.select({ picklist: 'industry', label: 'Industry' })
31683173
* // Results in: { type: 'select', picklist: 'industry', label: 'Industry' } — no `options`

0 commit comments

Comments
 (0)