Skip to content

Commit 0b91c34

Browse files
committed
Merge origin/main into the thread branch
Claude-Session: https://claude.ai/code/session_01ADHkmQNmyLgnBbCoc2iFjL Co-authored-by: Claude <noreply@anthropic.com>
2 parents 2dfa872 + c6075a7 commit 0b91c34

36 files changed

Lines changed: 2612 additions & 28 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/fields': patch
3+
---
4+
5+
fix(fields): a tap anywhere on a lookup picker option selects it, including on a record chip in its preview
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A lookup picker's option shows a preview of its other columns under its label. A column that references another record drew a link to that record there (on a record page, its chip), and a tap or a click on it opened that record instead of selecting the option, leaving the edit behind. An email, URL or phone column in the preview did the same with the mail client, the browser or the dialer.
11+
12+
The preview now draws every column the way the "browse all records" picker table already did: a reference keeps its face, the record page's chip included, without the link, and an email, URL, phone or file column shows its text. A tap or a click anywhere on the option selects it, on a phone and on a desktop. Both picker surfaces now take this rule from the one renderer they share.
13+
14+
What does not change: the read cells outside the picker (record page fields, list and grid cells) keep their links. No metadata key, value or default changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/plugin-detail': patch
4+
'@object-ui/i18n': patch
5+
'@object-ui/components': patch
6+
---
7+
8+
feat(console): an administrator configures the record page's tabs in place, from the record's 「…」
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: none
12+
13+
On the record page of an object whose package is writable (an object of a self-built app), a workspace administrator who may author metadata finds 「Configure tabs」 among the record's own entries in its 「…」 (desktop full page only; never on a phone, in a drawer or a pane, or on a page its author composed). Chosen, the page enters an edit state in place: a bar across the top with 「Configure tabs」, 「Cancel」 and 「Save」, in the design mode's bar's look, and the tab row turns into an editor. The record stays on screen as the preview, in the administrator's default order.
14+
15+
In the edit state the related tabs are dragged to a new order, hidden into a 「Hidden」 area and shown again from it, and renamed; the attachments tab can be hidden; 审批 and 动态, which the page always draws last, are shown fixed, and so is a list another package brings. 「Adjust field groups」 opens the object in Studio. 「Cancel」 drops the changes and writes nothing; leaving the page with a change held asks first.
16+
17+
「Save」 writes the object's `relatedLists` over the object as stored (never as served), as a draft with the first-write pin, and publishes it, so everyone sees the new default order, names and hidden tabs. An object's own `relatedLists` hides a tab by leaving it out; an entry the editor does not arrange (a 审批 / 动态 name, a list it does not offer) is kept. A reader's own dragged order still lays over the new default, and 「Restore default order」 returns them to it. A tab is renamed only in the app's source language, where its shown name is its stored one, the design-mode menu's rule.
18+
19+
New language-pack keys under `designMode.recordTabs` in all eleven console locales. `RecordPageColumns` takes an optional `tabRowEditor`, drawn in the tab row's place. Objects of installed (read-only) packages are not offered the entry yet.
20+
21+
`page:header`: a `⋯` entry that finished on the click (it returned no pending promise) now closes the menu, as Refresh does; an entry still running keeps the menu open with its row busy until it settles, as before.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the design-mode menu builds on a case-insensitive file system — its helper module no longer shares the component's name up to letter case
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`layout/` held the menu editor component `DesignModeMenu.tsx` beside its pure tree helpers `designModeMenu.ts`. On a case-insensitive file system (the macOS default) the sidebar's lazy `import('./DesignModeMenu.js')` tried `.ts` first and found the helper module, which has no default export: the `@object-ui/app-shell` build failed with TS1149 ("differs from already included file name … only in casing"), and a Console bundled there turned the whole page white when 「Edit app」 opened design mode. The helpers are now `designModeMenuModel.ts` (its test `designModeMenuModel-36363.test.ts`), so `./DesignModeMenu.js` can only reach the component. No behaviour changes; Linux builds were never affected.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/driver-sql': patch
3+
---
4+
5+
fix(driver-sql): removing a field's default stores NULL on MySQL 8, and never leaves a NOT NULL column refusing writes
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
#36245 made schema sync drop a column DEFAULT the field no longer declares. On MySQL 8 the drop left the column with no default at all, so an insert that omitted the field was refused ("Field … doesn't have a default value") where Postgres and SQLite store NULL. On a nullable column MySQL now sets the default to NULL instead, so an unset insert stores NULL on all three databases.
11+
12+
On a NOT NULL column the drop no longer travels alone, because the database would then refuse every insert that omits the field. When the field does not hold the column NOT NULL (no `storage.notNull` and not `required`, or `storage: { notNull: false }` in words), the drop is reported together with relaxing the column, both `needs_confirm`: `os migrate apply` applies them, and so do the publish of the object and the managed install of its package when the field declares `storage: { notNull: false }`. Afterwards an unset insert stores NULL. Dev auto-reconcile applies neither, as before for a relax. When the field still holds the column NOT NULL (`storage: { notNull: true }` or `required`), the column is left alone and the stale default is reported as `destructive`, which no automatic path applies. No metadata key, value or default changes.

‎packages/drivers/driver-sql/src/schema-drift.ts‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,12 @@ export function diffManagedTable(args: {
13441344
// explicit physical constraint — NOT against `required`, which is the
13451345
// write-time contract and implies nothing about the column) ──────────
13461346
const expectNullable = field.storage?.notNull !== true;
1347+
// [#36596] Whether a `relax_not_null` is proposed for this column: the
1348+
// literal-DEFAULT arm below drops a NOT NULL column's stale default only
1349+
// alongside it, never alone.
1350+
let relaxProposed = false;
13471351
if (expectNullable && !col.nullable && field.storage?.notNull === false && fieldName !== ceremonyOwnedNullability) {
1352+
relaxProposed = true;
13481353
// [#32590] The author DECLARED the column nullable — `storage: { notNull:
13491354
// false }`, written out, not merely absent. The column constraint is the
13501355
// declaration's to own (ADR-0113 D2), and this is the "deliberately
@@ -1385,6 +1390,7 @@ export function diffManagedTable(args: {
13851390
`package applies it ("os package install"); or relax it deliberately via "os migrate apply".`,
13861391
});
13871392
} else if (expectNullable && !col.nullable && field.required !== true && fieldName !== ceremonyOwnedNullability) {
1393+
relaxProposed = true;
13881394
// Column STRICTER than its declaration — and the field is not even
13891395
// write-gated, so an omitting write reaches the DB and dies as a raw
13901396
// driver error instead of a clean validation 400. That surprise is
@@ -1491,7 +1497,7 @@ export function diffManagedTable(args: {
14911497
const physical = physicalDefaultLiteral(col.defaultValue);
14921498
const multiValue = isMultiValueField({ type: String(field.type ?? ''), multiple: field.multiple === true });
14931499
if (physical.kind === 'literal' && !multiValue) {
1494-
if (dv === undefined || dv === null) {
1500+
if ((dv === undefined || dv === null) && col.nullable) {
14951501
out.push({
14961502
kind: 'default_mismatch',
14971503
remoteName: table,
@@ -1508,6 +1514,43 @@ export function diffManagedTable(args: {
15081514
`database stores nothing. Dropping the default is non-destructive and rewrites no stored row. ` +
15091515
SAFE_COLUMN_REMEDY,
15101516
});
1517+
} else if (dv === undefined || dv === null) {
1518+
// [#36596] A NOT NULL column. Dropping its only DEFAULT alone would
1519+
// turn every insert that omits the field from "stores the old value"
1520+
// into "refused by the database" — so the drop never travels alone.
1521+
// Where the declaration does not hold the column NOT NULL (the relax
1522+
// above is proposed: `storage.notNull: false` in words, or no storage
1523+
// declaration on a field that is not `required`), the drop travels
1524+
// WITH that relax at the relax's own category, `needs_confirm`, and
1525+
// is applied by the same deliberate acts (publish / package install
1526+
// for the declared-`false` case, #33724; `os migrate apply`), after
1527+
// which an omitting insert stores NULL. Anywhere else (`storage:
1528+
// { notNull: true }`, a `required` field, the ceremony-owned tenant
1529+
// column) the column is left alone: the entry is `destructive`, so no
1530+
// automatic path applies it, and it is reported (warned at boot, listed
1531+
// by "os migrate plan") rather than silently ignored.
1532+
const pairs = relaxProposed;
1533+
out.push({
1534+
kind: 'default_mismatch',
1535+
remoteName: table,
1536+
table,
1537+
column: fieldName,
1538+
expected: '(no column default)',
1539+
actual: `DEFAULT ${quoteDefaultForMessage(physical.text)}`,
1540+
severity: 'warning',
1541+
category: pairs ? 'needs_confirm' : 'destructive',
1542+
op: { type: 'drop_column_default', table, column: fieldName },
1543+
message: pairs
1544+
? `${table}.${fieldName}: the NOT NULL column carries DEFAULT ${quoteDefaultForMessage(physical.text)}, but the ` +
1545+
`field declares no default and does not hold the column NOT NULL. Dropping the default goes with ` +
1546+
`relaxing the column (reported alongside), so an insert that omits the field stores NULL, as on a new ` +
1547+
`database; neither statement rewrites a stored row. Apply both together: publish the object, install ` +
1548+
`the package that declares it, or run "os migrate apply".`
1549+
: `${table}.${fieldName}: the NOT NULL column carries DEFAULT ${quoteDefaultForMessage(physical.text)}, but the ` +
1550+
`field declares no default. Left as it is: the column stays NOT NULL, so dropping its default would ` +
1551+
`make the database refuse every insert that omits the field. Declare the default again, or relax the ` +
1552+
`column (\`storage: { notNull: false }\`) and the default is dropped with it.`,
1553+
});
15111554
} else if ((typeof dv === 'string' || typeof dv === 'number' || typeof dv === 'boolean') && !isRuntimeDefaultValue(dv)) {
15121555
if (physicalLiteralMatches(physical.text, dv, field.type) === false) {
15131556
out.push({

‎packages/drivers/driver-sql/src/sql-driver-36245-stale-literal-default.test.ts‎

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
* neither reported nor changed; a changed literal stores the new value; a row
2929
* stored before is not rewritten; and with no auto-reconcile the two entries
3030
* are reported `safe` and applied by the explicit apply door.
31+
*
32+
* [#36596] §3, one cell per dialect: the same removal on a NOT NULL column.
33+
* #36245 first shipped a MySQL `DROP DEFAULT`, which on MySQL 8 leaves even a
34+
* NULLABLE column with no default at all, so §2's unset insert was refused
35+
* ("Field 'digest' doesn't have a default value", ER 1364) — MariaDB 10.11,
36+
* where it was measured, stores NULL. §2 now holds on MySQL 8 as it stands. On
37+
* a NOT NULL column the drop never travels alone, since an omitting insert
38+
* would then be refused: where the declaration does not hold the column NOT
39+
* NULL it is paired with the `relax_not_null` (`needs_confirm`, both applied by
40+
* the explicit apply door, and by the publish when the field says `storage:
41+
* { notNull: false }` in words), after which an unset insert stores NULL;
42+
* where it does, the column is left alone and the entry reported `destructive`.
3143
*/
3244

3345
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -198,6 +210,128 @@ function measure(cell: DialectCell): void {
198210
expect(await second.detectManagedDrift([SECOND])).toEqual([]);
199211
});
200212
});
213+
214+
describe(`#36596 §3 — a stale literal DEFAULT on a NOT NULL column (${cell.label})`, () => {
215+
const NN = 'os36596_pref';
216+
const open: SqlDriver[] = [];
217+
let dir: string | undefined;
218+
219+
const config = (): Record<string, any> => {
220+
if (cell.id !== 'sqlite') return cell.config();
221+
dir ??= mkdtempSync(join(tmpdir(), 'os36596-'));
222+
return { ...cell.config(), connection: { filename: join(dir, 'db.sqlite') } };
223+
};
224+
225+
const boot = async (obj: any, opts: Record<string, any> = {}): Promise<SqlDriver> => {
226+
const driver = new SqlDriver({ ...config(), ...opts } as any);
227+
(driver as any).logger = quietLogger();
228+
open.push(driver);
229+
await driver.initObjects([obj]);
230+
return driver;
231+
};
232+
233+
const insertUnset = async (driver: SqlDriver, id: string) => {
234+
await driver.create(NN, { id, title: id }, { bypassTenantAudit: true } as any);
235+
return (driver as any).knex(NN).where('id', id).first();
236+
};
237+
238+
/** The first release: `code` is NOT NULL, with a literal default. */
239+
const FIRST_NN = {
240+
name: NN,
241+
fields: {
242+
title: { type: 'string' },
243+
code: { type: 'string', defaultValue: 'none', storage: { notNull: true } },
244+
},
245+
} as any;
246+
const second = (code: Record<string, any>) => ({ name: NN, fields: { title: { type: 'string' }, code: { type: 'string', ...code } } }) as any;
247+
248+
/** Create the first release's table, then boot the second declaration over it. */
249+
const upgrade = async (next: any, opts: Record<string, any> = {}): Promise<SqlDriver> => {
250+
const first = await boot(FIRST_NN);
251+
await (first as any).knex.schema.dropTableIfExists(NN);
252+
await first.initObjects([FIRST_NN]);
253+
await first.disconnect();
254+
open.splice(open.indexOf(first), 1);
255+
return boot(next, opts);
256+
};
257+
258+
const nullable = async (driver: SqlDriver): Promise<boolean> =>
259+
(await (driver as any).knex(NN).columnInfo())?.code?.nullable === true;
260+
261+
afterEach(async () => {
262+
const last = open[open.length - 1];
263+
if (last) await (last as any).knex.schema.dropTableIfExists(NN);
264+
for (const d of open.splice(0)) await d.disconnect();
265+
if (dir) rmSync(dir, { recursive: true, force: true });
266+
dir = undefined;
267+
});
268+
269+
it('no default, no storage declaration, not required: the drop is paired with the relax and an unset insert then stores NULL', async () => {
270+
const next = second({});
271+
const driver = await upgrade(next, { autoMigrate: 'safe', schemaMode: 'managed' });
272+
273+
const drift = await driver.detectManagedDrift([next]);
274+
expect(drift.map((d) => [d.column, d.op.type, d.category]).sort()).toEqual([
275+
['code', 'drop_column_default', 'needs_confirm'],
276+
['code', 'relax_not_null', 'needs_confirm'],
277+
]);
278+
// Dev auto-reconcile applies neither (ADR-0113 D5): the column is left as
279+
// it was, so an unset insert still stores the old default, never refused.
280+
expect(await nullable(driver)).toBe(false);
281+
expect((await insertUnset(driver, 'unrepaired')).code).toBe('none');
282+
283+
const { applied, skipped } = await driver.applyMigrationEntries(drift, { allowDestructive: false });
284+
expect(skipped).toEqual([]);
285+
expect(applied).toHaveLength(2);
286+
expect(await nullable(driver)).toBe(true);
287+
expect((await insertUnset(driver, 'repaired')).code).toBeNull();
288+
expect(await driver.detectManagedDrift([next])).toEqual([]);
289+
// The row stored before keeps what it holds.
290+
expect((await (driver as any).knex(NN).where('id', 'unrepaired').first()).code).toBe('none');
291+
});
292+
293+
it('`storage: { notNull: false }` declared: the publish applies the relax and the drop together', async () => {
294+
const next = second({ storage: { notNull: false } });
295+
const driver = await upgrade(next);
296+
expect((await insertUnset(driver, 'unrepaired')).code).toBe('none');
297+
298+
const { applied, skipped } = await driver.applyPublishedColumnChanges(next);
299+
expect(skipped).toEqual([]);
300+
expect(applied.map((d) => d.op.type).sort()).toEqual(['drop_column_default', 'relax_not_null']);
301+
expect((await insertUnset(driver, 'repaired')).code).toBeNull();
302+
expect(await driver.detectManagedDrift([next])).toEqual([]);
303+
});
304+
305+
it('a declaration that still holds the column NOT NULL: the column is left alone and the entry reported `destructive`', async () => {
306+
const next = second({ storage: { notNull: true } });
307+
const driver = await upgrade(next, { autoMigrate: 'safe', schemaMode: 'managed' });
308+
309+
const drift = await driver.detectManagedDrift([next]);
310+
expect(drift.map((d) => [d.column, d.op.type, d.category])).toEqual([['code', 'drop_column_default', 'destructive']]);
311+
expect(drift[0].message).toMatch(/Left as it is/);
312+
313+
// Neither the boot, the publish nor the non-destructive apply door touches it.
314+
expect((await driver.applyPublishedColumnChanges(next)).applied).toEqual([]);
315+
const { applied } = await driver.applyMigrationEntries(drift, { allowDestructive: false });
316+
expect(applied).toEqual([]);
317+
expect(await nullable(driver)).toBe(false);
318+
expect((await insertUnset(driver, 'kept')).code).toBe('none');
319+
});
320+
321+
it('a `required` field over the NOT NULL column (no storage declaration): left alone and reported `destructive`', async () => {
322+
const next = second({ required: true });
323+
const driver = await upgrade(next);
324+
325+
const drift = await driver.detectManagedDrift([next]);
326+
// The relax stays silent for a legacy `required` field (ADR-0113); the
327+
// stale default is reported, never applied by a non-destructive door.
328+
expect(drift.map((d) => [d.column, d.op.type, d.category])).toEqual([['code', 'drop_column_default', 'destructive']]);
329+
expect((await driver.applyMigrationEntries(drift, { allowDestructive: false })).applied).toEqual([]);
330+
expect(await nullable(driver)).toBe(false);
331+
await driver.create(NN, { id: 'r', title: 'r', code: 'given' }, { bypassTenantAudit: true } as any);
332+
expect((await (driver as any).knex(NN).where('id', 'r').first()).code).toBe('given');
333+
});
334+
});
201335
}
202336

203337
for (const cell of DIALECT_CELLS) {

0 commit comments

Comments
 (0)