Skip to content

Commit e47a9f8

Browse files
committed
fix(objectql): a write answers every stored declared column the driver did not echo as null, as the next read does (#29538)
Claude-Session: https://claude.ai/code/session_01ADHkmQjPiXgNoSaEpqeGvY Co-authored-by: Claude <noreply@anthropic.com>
1 parent fa07650 commit e47a9f8

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/objectql/src/declared-read-columns.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ export function rowsWithDeclaredColumnsOnly<T>(rows: T[], declared: ReadonlySet<
159159
* engine's own widening (formula inputs, a file field's owner key, each cut
160160
* back off the answer before the verb returns) are what count;
161161
* - no projection (a whole-record GET, a list read) selects every declared
162-
* column.
162+
* column;
163+
* - [#29538] a write's answer (the insert result, single or batch, and the
164+
* by-id update readback) names no projection either, so it is answered on
165+
* the whole stored record: the write answer equals the next read of the row.
163166
*
164167
* ## What stays absent, and why
165168
*

‎packages/objectql/src/engine.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16686,6 +16686,17 @@ export class ObjectQL implements IObjectQLEngine {
1668616686
result = isBatch
1668716687
? rowsWithDeclaredColumnsOnly(result as unknown[], declaredInsertColumns)
1668816688
: withDeclaredColumnsOnly(result, declaredInsertColumns);
16689+
// [#29538] …and answered on every stored declared column, as the next
16690+
// read of the row answers it (#29408): a column the driver did not
16691+
// echo (driver-mongodb and driver-memory store only written keys) is
16692+
// `null`. A write names no projection, so it selects the whole stored
16693+
// record. Before the formulas, so a formula over an unwritten column
16694+
// evaluates against `null` as the read's does; inside the verb, so the
16695+
// security middleware's field mask still deletes an FLS-refused key.
16696+
const insertAnswerColumns = selectedStoredColumns(schemaForValidation, undefined);
16697+
result = isBatch
16698+
? rowsWithSelectedColumnsAnswered(result as unknown[], insertAnswerColumns)
16699+
: withSelectedColumnsAnswered(result, insertAnswerColumns);
1668916700

1669016701
// Coerce `boolean` fields (SQLite/libsql return 0/1) to real booleans on
1669116702
// the after-hook view so flow trigger conditions (`record.is_escalated
@@ -18355,6 +18366,9 @@ export class ObjectQL implements IObjectQLEngine {
1835518366
// `data.record.updated` event and the door's ingress strip. A
1835618367
// `null` readback (the row left the caller's scope) stays `null`.
1835718368
result = withDeclaredColumnsOnly(result, declaredColumnSet(updateSchema));
18369+
// [#29538] Same answer on the stored declared columns as the
18370+
// insert result and the next read (#29408).
18371+
result = withSelectedColumnsAnswered(result, selectedStoredColumns(updateSchema, undefined));
1835818372
// [#27495] The handle the stored row named before, where this
1835918373
// statement cleared or replaced it.
1836018374
retiredSecrets = retiredSecretSlots(updateSchema, [priorRecord], hookContext.input.data);

0 commit comments

Comments
 (0)