Skip to content

Commit 908360f

Browse files
committed
test: align stale __unbound__/DDL expectations with public-default namespace
Update Postgres test assertions and helpers to index the `public` namespace instead of `__unbound__` for un-namespaced models, and refresh the E2E DDL inline snapshot for schema-qualified CREATE TABLE output. Also isolate Gemini CLI telemetry detection from host agent env markers. Signed-off-by: Will Madden <madden@prisma.io>
1 parent 06fbd7f commit 908360f

11 files changed

Lines changed: 53 additions & 50 deletions

File tree

packages/1-framework/3-tooling/cli-telemetry/test/integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ describe('cli-telemetry end-to-end via telemetry backend', () => {
255255
});
256256

257257
it('populates the agent field for Gemini CLI sessions', async () => {
258-
await spawnSenderDirect(buildPayload(), { ...process.env, GEMINI_CLI: '1' });
258+
await spawnSenderDirect(buildPayload(), { ...envWithoutAgentMarkers(), GEMINI_CLI: '1' });
259259
const [row] = await harness.awaitRows(1);
260260
expect(row?.agent).toBe('Gemini CLI');
261261
});

packages/1-framework/3-tooling/cli/test/load-ts-contract.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('loadContractFromTs', () => {
1818
expect(contract.targetFamily).toBe('sql');
1919
expect(contract.target).toBe('postgres');
2020
expect(contract.storage).toBeDefined();
21-
expect(contract.domain.namespaces['__unbound__']?.models).toBeDefined();
21+
expect(contract.domain.namespaces['public']?.models).toBeDefined();
2222
},
2323
timeouts.typeScriptCompilation,
2424
);

packages/3-extensions/postgres/test/psl-namespace-qualifier-routing.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('PSL → SqlStorage.namespaces qualifier routing (FR15 slice 3 + FR16a
114114
expect(namespace.qualifyTable('user')).toBe('"auth"."user"');
115115
});
116116

117-
it('top-level (implicit) models stay on the late-bound default — single-namespace contracts retain today\u2019s emit behaviour', () => {
117+
it('top-level (implicit) models lower to the public namespace with schema-qualified DDL', () => {
118118
const document = parsePslDocument({
119119
schema: `model Post {
120120
id Int @id
@@ -134,9 +134,14 @@ describe('PSL → SqlStorage.namespaces qualifier routing (FR15 slice 3 + FR16a
134134
return;
135135
}
136136
const storage = result.value.storage as SqlStorage;
137-
// Top-level declarations lower to the unbound namespace — the
138-
// planner falls back to its `ctx.schemaName` (today `"public"`)
139-
// for DDL qualification.
140-
expect(storage.namespaces[UNBOUND_NAMESPACE_ID]?.tables['post']).toBeDefined();
137+
expect(storage.namespaces['public']?.tables['post']).toBeDefined();
138+
139+
const namespace = storage.namespaces['public'];
140+
expect(namespace).toBeInstanceOf(PostgresSchema);
141+
expect(namespace).not.toBeInstanceOf(PostgresUnboundSchema);
142+
if (!(namespace instanceof PostgresSchema)) {
143+
throw new Error('expected PostgresSchema concretion');
144+
}
145+
expect(namespace.qualifyTable('post')).toBe('"public"."post"');
141146
});
142147
});

test/e2e/framework/test/ddl.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('DDL E2E Tests', { timeout: 30000 }, () => {
1414
expect(sql).toMatchInlineSnapshot(`
1515
"CREATE EXTENSION IF NOT EXISTS vector;
1616
17-
CREATE TABLE "comment" (
17+
CREATE TABLE "public"."comment" (
1818
"content" text NOT NULL,
1919
"created_at" timestamptz DEFAULT (now()) NOT NULL,
2020
"id" SERIAL NOT NULL,
@@ -23,22 +23,22 @@ describe('DDL E2E Tests', { timeout: 30000 }, () => {
2323
PRIMARY KEY ("id")
2424
);
2525
26-
CREATE TABLE "embedding" (
26+
CREATE TABLE "public"."embedding" (
2727
"embedding" vector(1536) NOT NULL,
2828
"id" SERIAL NOT NULL,
2929
"profile" jsonb NOT NULL,
3030
PRIMARY KEY ("id")
3131
);
3232
33-
CREATE TABLE "event" (
33+
CREATE TABLE "public"."event" (
3434
"created_at" timestamptz DEFAULT (now()) NOT NULL,
3535
"id" character(36) NOT NULL,
3636
"name" text NOT NULL,
3737
"scheduled_at" timestamptz DEFAULT '2024-01-15T10:30:00.000Z' NOT NULL,
3838
PRIMARY KEY ("id")
3939
);
4040
41-
CREATE TABLE "literal_defaults" (
41+
CREATE TABLE "public"."literal_defaults" (
4242
"active" bool DEFAULT true NOT NULL,
4343
"big_count" int8 DEFAULT 9007199254740991 NOT NULL,
4444
"id" SERIAL NOT NULL,
@@ -50,7 +50,7 @@ describe('DDL E2E Tests', { timeout: 30000 }, () => {
5050
PRIMARY KEY ("id")
5151
);
5252
53-
CREATE TABLE "param_types" (
53+
CREATE TABLE "public"."param_types" (
5454
"bits" bit varying(12),
5555
"code" character(16),
5656
"created_at" timestamptz(3),
@@ -64,7 +64,7 @@ describe('DDL E2E Tests', { timeout: 30000 }, () => {
6464
PRIMARY KEY ("id")
6565
);
6666
67-
CREATE TABLE "post" (
67+
CREATE TABLE "public"."post" (
6868
"created_at" timestamptz DEFAULT (now()) NOT NULL,
6969
"id" SERIAL NOT NULL,
7070
"meta" json,
@@ -75,7 +75,7 @@ describe('DDL E2E Tests', { timeout: 30000 }, () => {
7575
PRIMARY KEY ("id")
7676
);
7777
78-
CREATE TABLE "user" (
78+
CREATE TABLE "public"."user" (
7979
"created_at" timestamptz DEFAULT (now()) NOT NULL,
8080
"email" character varying(255) NOT NULL,
8181
"id" SERIAL NOT NULL,
@@ -84,7 +84,7 @@ describe('DDL E2E Tests', { timeout: 30000 }, () => {
8484
PRIMARY KEY ("id")
8585
);
8686
87-
ALTER TABLE "user" ADD CONSTRAINT "user_email_key" UNIQUE ("email")"
87+
ALTER TABLE "public"."user" ADD CONSTRAINT "user_email_key" UNIQUE ("email")"
8888
`);
8989
});
9090
});

test/integration/test/authoring/psl-index-type-options.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('PSL @@index type and options — integration with real paradedb pack',
3333
if (!result.ok) return;
3434
expect(result.value.storage).toMatchObject({
3535
namespaces: {
36-
__unbound__: {
36+
public: {
3737
tables: {
3838
doc: {
3939
indexes: [

test/integration/test/cli.db-sign.e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ withTempDir(({ createTempDir }) => {
351351
const contractPath = resolve(testSetup.testDir, 'src/prisma/contract.json');
352352
const { readFile, writeFile } = await import('node:fs/promises');
353353
const contractJson = JSON.parse(await readFile(contractPath, 'utf-8'));
354-
contractJson.storage.namespaces.__unbound__.tables.user.columns.email = {
354+
contractJson.storage.namespaces.public.tables.user.columns.email = {
355355
codecId: 'pg/text@1',
356356
nativeType: 'text',
357357
nullable: false,
@@ -395,7 +395,7 @@ withTempDir(({ createTempDir }) => {
395395
const contractPath = resolve(testSetup.testDir, 'src/prisma/contract.json');
396396
const { readFile, writeFile } = await import('node:fs/promises');
397397
const contractJson = JSON.parse(await readFile(contractPath, 'utf-8'));
398-
contractJson.storage.namespaces.__unbound__.tables.user.columns.email = {
398+
contractJson.storage.namespaces.public.tables.user.columns.email = {
399399
codecId: 'pg/text@1',
400400
nativeType: 'text',
401401
nullable: false,

test/integration/test/cli.emit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('emit command functionality', () => {
7070
target: 'postgres',
7171
storage: {
7272
namespaces: {
73-
__unbound__: {
73+
public: {
7474
tables: {
7575
user: expect.anything(),
7676
},

test/integration/test/sql-orm-client/helpers.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import postgresAdapter from '@prisma-next/adapter-postgres/runtime';
2-
import {
3-
contractModels,
4-
type Contract as FrameworkContract,
5-
UNBOUND_DOMAIN_NAMESPACE_ID,
6-
} from '@prisma-next/contract/types';
2+
import { contractModels, type Contract as FrameworkContract } from '@prisma-next/contract/types';
73
import pgvectorRuntime from '@prisma-next/extension-pgvector/runtime';
84
import { SqlContractSerializer } from '@prisma-next/family-sql/ir';
9-
import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
5+
6+
const POSTGRES_DEFAULT_NAMESPACE_ID = 'public' as const;
7+
108
import { AsyncIterableResult } from '@prisma-next/framework-components/runtime';
119
import type { SqlStorage } from '@prisma-next/sql-contract/types';
1210
import type { RuntimeQueryable } from '@prisma-next/sql-orm-client';
@@ -54,7 +52,7 @@ export function withPatchedDomainModels<T extends FrameworkContract<SqlStorage>>
5452
contract: T,
5553
patch: (models: Record<string, unknown>) => Record<string, unknown>,
5654
): T {
57-
const namespaceId = UNBOUND_DOMAIN_NAMESPACE_ID;
55+
const namespaceId = POSTGRES_DEFAULT_NAMESPACE_ID;
5856
const namespace = contract.domain.namespaces[namespaceId]!;
5957
const models = contractModels(contract);
6058
return {
@@ -83,7 +81,7 @@ type MutableDomainModel = {
8381
function unboundDomainModels(raw: {
8482
domain: { namespaces: Record<string, { models: Record<string, unknown> }> };
8583
}): Record<string, MutableDomainModel> {
86-
return raw.domain.namespaces[UNBOUND_DOMAIN_NAMESPACE_ID]!.models as Record<
84+
return raw.domain.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID]!.models as Record<
8785
string,
8886
MutableDomainModel
8987
>;
@@ -151,7 +149,7 @@ export function buildMixedPolyContract(): TestContract {
151149
base: 'Task',
152150
};
153151

154-
raw.storage.namespaces[UNBOUND_NAMESPACE_ID].tables.tasks = {
152+
raw.storage.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID].tables.tasks = {
155153
columns: {
156154
id: { nativeType: 'int4', codecId: 'pg/int4@1', nullable: false },
157155
title: { nativeType: 'text', codecId: 'pg/text@1', nullable: false },
@@ -164,7 +162,7 @@ export function buildMixedPolyContract(): TestContract {
164162
foreignKeys: [],
165163
};
166164

167-
raw.storage.namespaces[UNBOUND_NAMESPACE_ID].tables.features = {
165+
raw.storage.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID].tables.features = {
168166
columns: {
169167
id: { nativeType: 'int4', codecId: 'pg/int4@1', nullable: false },
170168
priority: { nativeType: 'int4', codecId: 'pg/int4@1', nullable: false },
@@ -216,17 +214,17 @@ export function buildStiPolyContract(): TestContract {
216214
base: 'User',
217215
};
218216

219-
raw.storage.namespaces[UNBOUND_NAMESPACE_ID].tables.users.columns.kind = {
217+
raw.storage.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID].tables.users.columns.kind = {
220218
codecId: 'pg/text@1',
221219
nativeType: 'text',
222220
nullable: false,
223221
};
224-
raw.storage.namespaces[UNBOUND_NAMESPACE_ID].tables.users.columns.role = {
222+
raw.storage.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID].tables.users.columns.role = {
225223
codecId: 'pg/text@1',
226224
nativeType: 'text',
227225
nullable: true,
228226
};
229-
raw.storage.namespaces[UNBOUND_NAMESPACE_ID].tables.users.columns.plan = {
227+
raw.storage.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID].tables.users.columns.plan = {
230228
codecId: 'pg/text@1',
231229
nativeType: 'text',
232230
nullable: true,
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
21
import type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';
32

3+
const POSTGRES_DEFAULT_NAMESPACE_ID = 'public' as const;
4+
45
type StorageLike = {
56
readonly namespaces: Readonly<
67
Record<string, { readonly tables?: Readonly<Record<string, unknown>> }>
@@ -10,7 +11,7 @@ type StorageLike = {
1011
export function unboundTables(
1112
storage: StorageLike | SqlStorage,
1213
): Readonly<Record<string, StorageTable>> {
13-
return (storage.namespaces[UNBOUND_NAMESPACE_ID]?.tables ?? {}) as Readonly<
14+
return (storage.namespaces[POSTGRES_DEFAULT_NAMESPACE_ID]?.tables ?? {}) as Readonly<
1415
Record<string, StorageTable>
1516
>;
1617
}

test/integration/test/value-objects/value-objects.integration.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
UNBOUND_DOMAIN_NAMESPACE_ID,
77
} from '@prisma-next/contract/types';
88
import { MongoContractSerializer } from '@prisma-next/family-mongo/ir';
9-
import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
109
import { interpretPslDocumentToMongoContract } from '@prisma-next/mongo-contract-psl';
1110
import { mongoOrm } from '@prisma-next/mongo-orm';
1211
import { parsePslDocument } from '@prisma-next/psl-parser';
@@ -190,17 +189,17 @@ describe('value objects: end-to-end SQL pipeline', () => {
190189
if (!result.ok) throw new Error(`Interpretation failed: ${result.failure.summary}`);
191190

192191
const contract = result.value;
193-
const unboundDomain = contract.domain.namespaces[UNBOUND_DOMAIN_NAMESPACE_ID]!;
194-
expect(unboundDomain.valueObjects).toBeDefined();
195-
expect(unboundDomain.valueObjects!['Address']).toBeDefined();
192+
const publicDomain = contract.domain.namespaces['public']!;
193+
expect(publicDomain.valueObjects).toBeDefined();
194+
expect(publicDomain.valueObjects!['Address']).toBeDefined();
196195

197-
const addressVo = unboundDomain.valueObjects!['Address'] as ContractValueObject;
196+
const addressVo = publicDomain.valueObjects!['Address'] as ContractValueObject;
198197
const voFields = addressVo.fields;
199198
expect(voFields['street']).toBeDefined();
200199
expect(voFields['city']).toBeDefined();
201200
expect(voFields['zip']).toBeDefined();
202201

203-
const userFields = unboundDomain.models['User']!.fields as Record<string, ContractField>;
202+
const userFields = publicDomain.models['User']!.fields as Record<string, ContractField>;
204203
const homeAddressField = userFields['homeAddress']!;
205204
expect(homeAddressField.type).toEqual({ kind: 'valueObject', name: 'Address' });
206205
expect(homeAddressField.nullable).toBe(false);
@@ -211,7 +210,7 @@ describe('value objects: end-to-end SQL pipeline', () => {
211210
{ tables: Record<string, { columns: Record<string, { nativeType: string }> }> }
212211
>;
213212
};
214-
const userTable = storage.namespaces[UNBOUND_NAMESPACE_ID]!.tables['user'];
213+
const userTable = storage.namespaces['public']!.tables['user'];
215214
expect(userTable).toBeDefined();
216215
expect(userTable!.columns['homeAddress']).toBeDefined();
217216
expect(userTable!.columns['homeAddress']!.nativeType).toBe('jsonb');

0 commit comments

Comments
 (0)