Skip to content

Commit 88440a1

Browse files
committed
fix(metadata-core): lock_state keeps the varchar(255) width the select column was created with
Claude-Session: https://claude.ai/code/session_0123qkvzKLQfRRRnuR8wanHJ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9b40625 commit 88440a1

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎packages/metadata-core/src/objects/sys-metadata-audit-lock-state.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ import { SysMetadataAuditObject } from './sys-metadata-audit.object.js';
1919
describe('sys_metadata_audit.lock_state (#25013)', () => {
2020
const field = SysMetadataAuditObject.fields.lock_state as Record<string, unknown>;
2121

22-
it('is a text column with no option list of its own and no width', () => {
22+
it('is a text column with no option list of its own, as wide as the select column was', () => {
2323
expect(field.type).toBe('text');
2424
expect(field).not.toHaveProperty('options');
25-
// No `maxLength`: an existing `varchar(255)` column reports no width drift.
26-
expect(field).not.toHaveProperty('maxLength');
25+
// The `varchar(255)` a select column is created as: an existing database
26+
// reports no drift (no `maxLength` would read as varchar → text).
27+
expect(field.maxLength).toBe(255);
2728
expect(field.readonly).toBe(true);
2829
});
2930

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,16 @@ export const SysMetadataAuditObject = ObjectSchema.create({
193193
* `Field.select([...])` shorthand used to strip the hyphen, declaring
194194
* `nooverlay` / `nodelete` — values no row ever held (#25013). Like `code`
195195
* above, the closed set lives with its writer (`MetadataLockSchema`).
196-
* No `maxLength`: existing columns keep their width and report no drift.
196+
* `maxLength: 255` is the `varchar(255)` the select column was created
197+
* as, so an existing database reports no drift: measured with
198+
* `diffManagedTable` on postgres / mysql / sqlite, no `maxLength` reads as a
199+
* varchar → text type change and a narrower one as a destructive narrowing.
197200
*/
198201
lock_state: Field.text({
199202
label: 'Lock State',
200203
required: false,
201204
readonly: true,
205+
maxLength: 255,
202206
}),
203207

204208
/** True when the write succeeded by bypassing a lock (Phase 3). */

0 commit comments

Comments
 (0)