Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/objectql/src/bulk-write-per-row-hooks.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -468,7 +468,7 @@ async function seedTasks(engine: ObjectQL, rows: Record<string, unknown>[]): Pro
return Array.isArray(written) ? written : [written];
}

function makeMemoryDriver(): any {
function makeStubDriver(): any {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => {
let s = stores.get(o);
Expand DownExpand Up@@ -528,7 +528,7 @@ function makeMemoryDriver(): any {

async function boot(hooks: Hook[]): Promise<{ engine: ObjectQL; driver: any }> {
const engine = new ObjectQL();
const driver = makeMemoryDriver();
const driver = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
engine.registry.registerObject(taskObject as any);
Expand Down
8 changes: 4 additions & 4 deletions packages/objectql/src/engine-audit-anchor-write.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@
* [#4447] `created_at` is engine-owned: a client-supplied value on an ordinary
* write is DROPPED, not persisted.
*
* Reproduction harness: a REAL {@link ObjectQL} engine over a minimal in-memory
* Reproduction harness: a REAL {@link ObjectQL} engine over a minimal stub
* driver whose `update` lets incoming data win (`{...cur, ...data}`) — the same
* shape driver-sql has, which is why a value that survives the engine's strip
* reaches the row.
Expand All@@ -23,7 +23,7 @@ const taskObject = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (obj: string) => {
let s = stores.get(obj);
Expand DownExpand Up@@ -106,7 +106,7 @@ describe('[#4447] created_at is engine-owned on an ordinary write', () => {

beforeEach(async () => {
engine = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
engine.registry.registerObject(taskObject as any);
Expand DownExpand Up@@ -252,7 +252,7 @@ describe('[#4447] a declared audit field cannot loosen the platform posture', ()
let engine: ObjectQL;
beforeEach(async () => {
engine = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
engine.registry.registerObject(shadowed as any);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ const ACCOUNT = {
},
};

function makeMemoryDriver(opts: { nativeAutonumber?: boolean } = {}) {
function makeStubDriver(opts: { nativeAutonumber?: boolean } = {}) {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const createdRows: Array<Record<string, unknown>> = [];
const updatedPayloads: Array<Record<string, unknown>> = [];
Expand DownExpand Up@@ -153,7 +153,7 @@ function makeMemoryDriver(opts: { nativeAutonumber?: boolean } = {}) {

async function makeEngine(opts: { nativeAutonumber?: boolean } = {}) {
const engine = new ObjectQL();
const rig = makeMemoryDriver(opts);
const rig = makeStubDriver(opts);
engine.registerDriver(rig.driver, true);
await engine.init();
engine.registry.registerObject(ACCOUNT as any);
Expand Down
6 changes: 3 additions & 3 deletions packages/objectql/src/engine-cascade-delete.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@

/**
* Cascade-on-delete behavior for parent→child foreign keys, with a REAL
* {@link ObjectQL} engine + in-memory driver.
* {@link ObjectQL} engine + stub driver.
*
* Regression: deleting a parent whose child has a *required* lookup FK used to
* default to `set_null`, issuing an UPDATE that cleared the required FK — which
Expand DownExpand Up@@ -56,7 +56,7 @@ const taskCascade = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => { let s = stores.get(o); if (!s) { s = new Map(); stores.set(o, s); } return s; };
let nextId = 0;
Expand DownExpand Up@@ -96,7 +96,7 @@ describe('cascadeDeleteRelations — required FK escalates set_null → restrict

beforeEach(async () => {
engine = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
for (const o of [acct, oppRequired, noteOptional, taskCascade]) engine.registry.registerObject(o as any);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,7 +61,7 @@ const history = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (obj: string) => {
let s = stores.get(obj);
Expand DownExpand Up@@ -140,9 +140,9 @@ describe('[#4551] the engine reports the dangling rows its own `isSystem` exempt

beforeEach(async () => {
engine = new ObjectQL();
const mem = makeMemoryDriver();
stores = mem.stores;
engine.registerDriver(mem.driver, true);
const stub = makeStubDriver();
stores = stub.stores;
engine.registerDriver(stub.driver, true);
await engine.init();
engine.registry.registerObject(permissionSet as any);
engine.registry.registerObject(binding as any);
Expand Down
6 changes: 3 additions & 3 deletions packages/objectql/src/engine-data-events.bench.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
* Each pair below is the SAME write with and without a realtime service
* attached, so the delta is exactly the event-publishing work: uuid generation,
* schema validation, envelope construction, and the (no-op) publish. The
* in-memory driver keeps driver cost near zero, which flatters the event cost —
* stub driver keeps driver cost near zero, which flatters the event cost —
* i.e. the relative overhead measured here is an upper bound on what a real
* SQL/HTTP driver would show.
*/
Expand All@@ -34,7 +34,7 @@ const task = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => {
let s = stores.get(o);
Expand DownExpand Up@@ -102,7 +102,7 @@ const nullRealtime: IRealtimeService = {

async function makeEngine(withRealtime: boolean): Promise<ObjectQL> {
const engine = new ObjectQL();
engine.registerDriver(makeMemoryDriver(), true);
engine.registerDriver(makeStubDriver(), true);
await engine.init();
engine.registry.registerObject(task as any, 'bench');
if (withRealtime) engine.setRealtimeService(nullRealtime);
Expand Down
10 changes: 5 additions & 5 deletions packages/objectql/src/engine-data-events.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,7 @@ const task = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => {
let s = stores.get(o);
Expand DownExpand Up@@ -118,7 +118,7 @@ describe('#4626 — engine writes publish true DataEvents', () => {
unsubscribe: vi.fn(async () => undefined),
};
engine = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
engine.registry.registerObject(task as any);
Expand DownExpand Up@@ -216,7 +216,7 @@ describe('#4626 — engine writes publish true DataEvents', () => {

it('publishes nothing at all when no realtime service is configured', async () => {
const bare = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
bare.registerDriver(driver, true);
await bare.init();
bare.registry.registerObject(task as any);
Expand DownExpand Up@@ -253,7 +253,7 @@ describe('#4639 — predicate writes publish aggregate BulkDataEvents', () => {
unsubscribe: vi.fn(async () => undefined),
};
engine = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
engine.registry.registerObject(task as any);
Expand DownExpand Up@@ -351,7 +351,7 @@ describe('#4639 — predicate writes publish aggregate BulkDataEvents', () => {

it('publishes NOTHING when the driver breaks its count contract — and says so', async () => {
const offContract = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
// `updateMany` is contracted to resolve the affected count. A driver that
// resolves something else leaves `matched` unknowable, and `matched` is the
// entire substance of a bulk event — so none is published.
Expand Down
9 changes: 5 additions & 4 deletions packages/objectql/src/engine-default-value-tokens.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ import { DEFAULT_VALUE_TOKEN_CURRENT_USER, DEFAULT_VALUE_TOKEN_NOW } from '@obje
/** `YYYY-MM-DDTHH:MM:SS.sssZ` — the canonical stored instant (ADR-0053). */
const ISO_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (obj: string) => {
let s = stores.get(obj);
Expand DownExpand Up@@ -88,7 +88,7 @@ describe('[#4560] the `current_user` defaultValue token is engine-owned', () =>

beforeEach(async () => {
engine = new ObjectQL();
engine.registerDriver(makeMemoryDriver().driver, true);
engine.registerDriver(makeStubDriver().driver, true);
await engine.init();
engine.registry.registerObject(owned as any);
});
Expand DownExpand Up@@ -145,7 +145,7 @@ describe('[#4597] the `NOW()` defaultValue token is engine-owned too', () => {

beforeEach(async () => {
engine = new ObjectQL();
engine.registerDriver(makeMemoryDriver().driver, true);
engine.registerDriver(makeStubDriver().driver, true);
await engine.init();
engine.registry.registerObject(stamped as any);
});
Expand All@@ -154,7 +154,8 @@ describe('[#4597] the `NOW()` defaultValue token is engine-owned too', () => {
// Before the fix this threw `ValidationError: seen_at must be a valid
// datetime (ISO-8601)`: the engine filled the field with the literal
// string 'NOW()' and its own validator then rejected the insert. The
// memory driver has no `formatInput` safety net to hide it behind.
// stub driver, like every non-SQL driver, has no `formatInput` safety net
// to hide it behind.
const row: any = await engine.insert('probe_now', {}, { context: { isSystem: true } } as any);
expect(row.seen_at).not.toBe('NOW()');
expect(row.seen_at).toMatch(ISO_INSTANT);
Expand Down
10 changes: 5 additions & 5 deletions packages/objectql/src/engine-filter-alias.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@

/**
* #4346 — the `filter` → `where` alias folds on EVERY engine entry point, not
* just `find()`, with a REAL {@link ObjectQL} engine + in-memory driver.
* just `find()`, with a REAL {@link ObjectQL} engine + stub driver.
*
* Regression: the DataEngine contract (`DataEngine*OptionsSchema`) declares
* `filter` as a legitimate option on every read and write method, but only
Expand DownExpand Up@@ -37,7 +37,7 @@ const task = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => { let s = stores.get(o); if (!s) { s = new Map(); stores.set(o, s); } return s; };
let nextId = 0;
Expand DownExpand Up@@ -99,9 +99,9 @@ describe('filter → where folds on every engine method (#4346)', () => {

beforeEach(async () => {
engine = new ObjectQL();
const mem = makeMemoryDriver();
stores = mem.stores;
engine.registerDriver(mem.driver, true);
const stub = makeStubDriver();
stores = stub.stores;
engine.registerDriver(stub.driver, true);
await engine.init();
engine.registry.registerObject(task as any);
// The issue's repro set: one open row, two done rows.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,7 +67,7 @@ const task = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (obj: string) => {
let s = stores.get(obj);
Expand DownExpand Up@@ -150,9 +150,9 @@ describe('[#4441] a lookup id that resolves to nothing is refused', () => {

beforeEach(async () => {
engine = new ObjectQL();
const mem = makeMemoryDriver();
stores = mem.stores;
engine.registerDriver(mem.driver, true);
const stub = makeStubDriver();
stores = stub.stores;
engine.registerDriver(stub.driver, true);
await engine.init();
engine.registry.registerObject(permissionSet as any);
engine.registry.registerObject(binding as any);
Expand Down
21 changes: 11 additions & 10 deletions packages/objectql/src/engine-write-formula-hydration.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ const MEMO = {
},
};

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (obj: string) => {
let s = stores.get(obj);
Expand DownExpand Up@@ -154,14 +154,15 @@ function makeMemoryDriver() {
async disconnect() {},
async checkHealth() { return true; },
async execute() { return null; },
// Shallow COPIES, never live references into the backing table — the
// contract `driver-memory` states in as many words, and the SQL driver gets
// for free from knex. It is load-bearing for this file specifically: the
// READ path hydrates formulas by mutating the rows a driver hands back, so
// a harness leaking references would write `display_title` into its own
// store on the first GET and every later write response would echo it —
// these tests would then pass with the write-path hydration deleted, which
// is the "green because nothing is produced" failure mode, inverted.
// Shallow COPIES, never live references into the backing table — the shape
// every real backend hands back (a SQL driver gets it for free from knex; an
// in-process store has to copy explicitly). It is load-bearing for this
// file specifically: the READ path hydrates formulas by mutating the rows a
// driver hands back, so a harness leaking references would write
// `display_title` into its own store on the first GET and every later
// write response would echo it — these tests would then pass with the
// write-path hydration deleted, which is the "green because nothing is
// produced" failure mode, inverted.
async find(object: string, ast: { where?: unknown }) {
return Array.from(storeFor(object).values())
.filter((r) => matchesWhere(r, ast?.where))
Expand DownExpand Up@@ -222,7 +223,7 @@ function makeMemoryDriver() {

async function makeEngine() {
const engine = new ObjectQL();
const rig = makeMemoryDriver();
const rig = makeStubDriver();
engine.registerDriver(rig.driver as never, true);
await engine.init();
for (const obj of [ACCOUNT, FORECAST, PLAIN, MEMO]) {
Expand Down
4 changes: 2 additions & 2 deletions packages/objectql/src/hook-condition-bulk-previous.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -479,7 +479,7 @@ describe('[#5038] the diagnostic is RETIRED for after-type hooks', () => {
* Real-engine harness (mirrors hook-condition-fail-loud.test.ts)
* ──────────────────────────────────────────────────────────────────────────── */

function makeMemoryDriver(): any {
function makeStubDriver(): any {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => {
let s = stores.get(o);
Expand DownExpand Up@@ -534,7 +534,7 @@ function makeMemoryDriver(): any {

async function bootEngine(hooks: Hook[]): Promise<ObjectQL> {
const engine = new ObjectQL();
engine.registerDriver(makeMemoryDriver(), true);
engine.registerDriver(makeStubDriver(), true);
await engine.init();
engine.registry.registerObject(taskObject as any);
bindHooksToEngine(engine, hooks, { packageId: 'app:test', logger: silentLogger });
Expand Down
4 changes: 2 additions & 2 deletions packages/objectql/src/hook-condition-fail-loud.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -458,7 +458,7 @@ describe('[#4775] a condition that does not compile aborts too', () => {
* Real-engine harness
* ──────────────────────────────────────────────────────────────────────────── */

function makeMemoryDriver(): any {
function makeStubDriver(): any {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (o: string) => {
let s = stores.get(o);
Expand DownExpand Up@@ -508,7 +508,7 @@ function makeMemoryDriver(): any {

async function bootEngine(hooks: Hook[]): Promise<ObjectQL> {
const engine = new ObjectQL();
engine.registerDriver(makeMemoryDriver(), true);
engine.registerDriver(makeStubDriver(), true);
await engine.init();
engine.registry.registerObject(taskObject as any);
bindHooksToEngine(engine, hooks, { packageId: 'app:test', logger: silentLogger });
Expand Down
8 changes: 4 additions & 4 deletions packages/objectql/src/hook-condition-merged-record.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -226,12 +226,12 @@ describe('[#4770] hook condition evaluates against stored ⊕ payload', () => {
*
* `rm -rf examples/app-showcase/.objectstack && pnpm dev` printed ten
* `condition evaluation failed` lines for `showcase_audit_task_completion`.
* This is the same object/hook shape driven through a REAL engine over an
* in-memory driver that — like a SQL driver — stores only the columns a write
* This is the same object/hook shape driven through a REAL engine over a
* stub driver that — like a SQL driver — stores only the columns a write
* actually touched.
* ──────────────────────────────────────────────────────────────────────────── */

function makeMemoryDriver() {
function makeStubDriver() {
const stores = new Map<string, Map<string, Record<string, unknown>>>();
const storeFor = (obj: string) => {
let s = stores.get(obj);
Expand DownExpand Up@@ -309,7 +309,7 @@ describe('[#4770] showcase repro — showcase_audit_task_completion over a real

beforeEach(async () => {
engine = new ObjectQL();
const { driver } = makeMemoryDriver();
const { driver } = makeStubDriver();
engine.registerDriver(driver, true);
await engine.init();
engine.registry.registerObject(taskObject as any);
Expand Down
Loading
Loading