@prisma-next/adapter-postgres 0.5.0-dev.7 → 0.5.0-dev.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +14 -16
  2. package/dist/adapter-MsS4g_NL.mjs +47 -0
  3. package/dist/adapter-MsS4g_NL.mjs.map +1 -0
  4. package/dist/adapter.d.mts +3 -4
  5. package/dist/adapter.d.mts.map +1 -1
  6. package/dist/adapter.mjs +2 -3
  7. package/dist/column-types.d.mts +19 -24
  8. package/dist/column-types.d.mts.map +1 -1
  9. package/dist/column-types.mjs +20 -60
  10. package/dist/column-types.mjs.map +1 -1
  11. package/dist/control.d.mts +83 -3
  12. package/dist/control.d.mts.map +1 -1
  13. package/dist/control.mjs +74 -14
  14. package/dist/control.mjs.map +1 -1
  15. package/dist/{descriptor-meta-RTDzyrae.mjs → descriptor-meta-C2VasIft.mjs} +36 -27
  16. package/dist/descriptor-meta-C2VasIft.mjs.map +1 -0
  17. package/dist/operation-types.d.mts +11 -10
  18. package/dist/operation-types.d.mts.map +1 -1
  19. package/dist/operation-types.mjs +1 -1
  20. package/dist/runtime.d.mts +3 -11
  21. package/dist/runtime.d.mts.map +1 -1
  22. package/dist/runtime.mjs +19 -81
  23. package/dist/runtime.mjs.map +1 -1
  24. package/dist/{sql-renderer-pEaSP82_.mjs → sql-renderer-_cLtu1Av.mjs} +95 -48
  25. package/dist/sql-renderer-_cLtu1Av.mjs.map +1 -0
  26. package/dist/{types-CfRPdAk8.d.mts → types-B1eiuBHQ.d.mts} +12 -1
  27. package/dist/types-B1eiuBHQ.d.mts.map +1 -0
  28. package/dist/types.d.mts +1 -1
  29. package/dist/types.mjs +1 -1
  30. package/package.json +24 -23
  31. package/src/core/adapter.ts +17 -42
  32. package/src/core/codec-lookup.ts +19 -0
  33. package/src/core/control-adapter.ts +119 -1
  34. package/src/core/control-mutation-defaults.ts +24 -18
  35. package/src/core/descriptor-meta.ts +39 -19
  36. package/src/core/sql-renderer.ts +111 -66
  37. package/src/core/types.ts +11 -0
  38. package/src/exports/column-types.ts +21 -61
  39. package/src/exports/control.ts +3 -2
  40. package/src/exports/runtime.ts +27 -66
  41. package/src/types/operation-types.ts +19 -9
  42. package/dist/adapter-hNElNHo4.mjs +0 -60
  43. package/dist/adapter-hNElNHo4.mjs.map +0 -1
  44. package/dist/descriptor-meta-RTDzyrae.mjs.map +0 -1
  45. package/dist/sql-renderer-pEaSP82_.mjs.map +0 -1
  46. package/dist/types-CfRPdAk8.d.mts.map +0 -1
  47. package/src/core/json-schema-validator.ts +0 -54
  48. package/src/core/standard-schema.ts +0 -71
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@prisma-next/adapter-postgres",
3
- "version": "0.5.0-dev.7",
3
+ "version": "0.5.0-dev.70",
4
+ "license": "Apache-2.0",
4
5
  "type": "module",
5
6
  "sideEffects": false,
6
7
  "files": [
@@ -8,32 +9,32 @@
8
9
  "src"
9
10
  ],
10
11
  "dependencies": {
11
- "ajv": "^8.18.0",
12
- "arktype": "^2.0.0",
13
- "@prisma-next/contract": "0.5.0-dev.7",
14
- "@prisma-next/contract-authoring": "0.5.0-dev.7",
15
- "@prisma-next/framework-components": "0.5.0-dev.7",
16
- "@prisma-next/ids": "0.5.0-dev.7",
17
- "@prisma-next/family-sql": "0.5.0-dev.7",
18
- "@prisma-next/sql-contract": "0.5.0-dev.7",
19
- "@prisma-next/sql-contract-psl": "0.5.0-dev.7",
20
- "@prisma-next/sql-contract-ts": "0.5.0-dev.7",
21
- "@prisma-next/sql-operations": "0.5.0-dev.7",
22
- "@prisma-next/sql-relational-core": "0.5.0-dev.7",
23
- "@prisma-next/sql-runtime": "0.5.0-dev.7",
24
- "@prisma-next/target-postgres": "0.5.0-dev.7",
25
- "@prisma-next/utils": "0.5.0-dev.7",
26
- "@prisma-next/sql-schema-ir": "0.5.0-dev.7"
12
+ "arktype": "^2.1.29",
13
+ "@prisma-next/contract": "0.5.0-dev.70",
14
+ "@prisma-next/contract-authoring": "0.5.0-dev.70",
15
+ "@prisma-next/family-sql": "0.5.0-dev.70",
16
+ "@prisma-next/ids": "0.5.0-dev.70",
17
+ "@prisma-next/sql-contract": "0.5.0-dev.70",
18
+ "@prisma-next/sql-contract-ts": "0.5.0-dev.70",
19
+ "@prisma-next/sql-operations": "0.5.0-dev.70",
20
+ "@prisma-next/sql-relational-core": "0.5.0-dev.70",
21
+ "@prisma-next/framework-components": "0.5.0-dev.70",
22
+ "@prisma-next/sql-contract-psl": "0.5.0-dev.70",
23
+ "@prisma-next/sql-runtime": "0.5.0-dev.70",
24
+ "@prisma-next/sql-schema-ir": "0.5.0-dev.70",
25
+ "@prisma-next/target-postgres": "0.5.0-dev.70",
26
+ "@prisma-next/utils": "0.5.0-dev.70"
27
27
  },
28
28
  "devDependencies": {
29
29
  "pathe": "^2.0.3",
30
- "tsdown": "0.18.4",
30
+ "tsdown": "0.22.0",
31
31
  "typescript": "5.9.3",
32
- "vitest": "4.0.17",
33
- "@prisma-next/cli": "0.5.0-dev.7",
34
- "@prisma-next/errors": "0.5.0-dev.7",
35
- "@prisma-next/driver-postgres": "0.5.0-dev.7",
36
- "@prisma-next/extension-pgvector": "0.5.0-dev.7",
32
+ "vitest": "4.1.5",
33
+ "@prisma-next/cli": "0.5.0-dev.70",
34
+ "@prisma-next/driver-postgres": "0.5.0-dev.70",
35
+ "@prisma-next/extension-pgvector": "0.5.0-dev.70",
36
+ "@prisma-next/errors": "0.5.0-dev.70",
37
+ "@prisma-next/migration-tools": "0.5.0-dev.70",
37
38
  "@prisma-next/test-utils": "0.0.1",
38
39
  "@prisma-next/tsconfig": "0.0.0",
39
40
  "@prisma-next/tsdown": "0.0.0"
@@ -1,13 +1,13 @@
1
- import {
2
- type Adapter,
3
- type AdapterProfile,
4
- type AnyQueryAst,
5
- type CodecParamsDescriptor,
6
- createCodecRegistry,
7
- type LowererContext,
1
+ import type { CodecLookup } from '@prisma-next/framework-components/codec';
2
+ import { APP_SPACE_ID } from '@prisma-next/framework-components/control';
3
+ import type {
4
+ Adapter,
5
+ AdapterProfile,
6
+ AnyQueryAst,
7
+ LowererContext,
8
8
  } from '@prisma-next/sql-relational-core/ast';
9
- import { codecDefinitions } from '@prisma-next/target-postgres/codecs';
10
- import { ifDefined } from '@prisma-next/utils/defined';
9
+ import { parseContractMarkerRow } from '@prisma-next/sql-runtime';
10
+ import { createPostgresBuiltinCodecLookup } from './codec-lookup';
11
11
  import { renderLoweredSql } from './sql-renderer';
12
12
  import type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';
13
13
 
@@ -26,58 +26,33 @@ const defaultCapabilities = Object.freeze({
26
26
  },
27
27
  });
28
28
 
29
- type AdapterCodec = (typeof codecDefinitions)[keyof typeof codecDefinitions]['codec'];
30
- type ParameterizedCodec = AdapterCodec & {
31
- readonly paramsSchema: NonNullable<AdapterCodec['paramsSchema']>;
32
- };
33
-
34
- const parameterizedCodecs: ReadonlyArray<CodecParamsDescriptor> = Object.values(codecDefinitions)
35
- .map((definition) => definition.codec)
36
- .filter((codec): codec is ParameterizedCodec => codec.paramsSchema !== undefined)
37
- .map((codec) =>
38
- Object.freeze({
39
- codecId: codec.id,
40
- paramsSchema: codec.paramsSchema,
41
- ...ifDefined('init', codec.init),
42
- }),
43
- );
44
-
45
29
  class PostgresAdapterImpl
46
30
  implements Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement>
47
31
  {
48
- // These fields make the adapter instance structurally compatible with
49
- // RuntimeAdapterInstance<'sql', 'postgres'> without introducing a runtime-plane dependency.
32
+ // These fields make the adapter instance structurally compatible with RuntimeAdapterInstance<'sql', 'postgres'> without introducing a runtime-plane dependency.
50
33
  readonly familyId = 'sql' as const;
51
34
  readonly targetId = 'postgres' as const;
52
35
 
53
36
  readonly profile: AdapterProfile<'postgres'>;
54
- private readonly codecRegistry = (() => {
55
- const registry = createCodecRegistry();
56
- for (const definition of Object.values(codecDefinitions)) {
57
- registry.register(definition.codec);
58
- }
59
- return registry;
60
- })();
37
+ private readonly codecLookup: CodecLookup;
61
38
 
62
39
  constructor(options?: PostgresAdapterOptions) {
40
+ this.codecLookup = options?.codecLookup ?? createPostgresBuiltinCodecLookup();
63
41
  this.profile = Object.freeze({
64
42
  id: options?.profileId ?? 'postgres/default@1',
65
43
  target: 'postgres',
66
44
  capabilities: defaultCapabilities,
67
- codecs: () => this.codecRegistry,
68
45
  readMarkerStatement: () => ({
69
- sql: 'select core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta from prisma_contract.marker where id = $1',
70
- params: [1],
46
+ sql: 'select core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta, invariants from prisma_contract.marker where space = $1',
47
+ params: [APP_SPACE_ID],
71
48
  }),
49
+ // Postgres' driver hydrates `text[]` columns as native JS arrays, so the row is already in the shape the shared parser expects.
50
+ parseMarkerRow: (row: unknown) => parseContractMarkerRow(row),
72
51
  });
73
52
  }
74
53
 
75
- parameterizedCodecs(): ReadonlyArray<CodecParamsDescriptor> {
76
- return parameterizedCodecs;
77
- }
78
-
79
54
  lower(ast: AnyQueryAst, context: LowererContext<PostgresContract>): PostgresLoweredStatement {
80
- return renderLoweredSql(ast, context.contract);
55
+ return renderLoweredSql(ast, context.contract, this.codecLookup);
81
56
  }
82
57
  }
83
58
 
@@ -0,0 +1,19 @@
1
+ import type { CodecLookup } from '@prisma-next/framework-components/codec';
2
+ import { extractCodecLookup } from '@prisma-next/framework-components/control';
3
+ import { postgresCodecRegistry } from '@prisma-next/target-postgres/codecs';
4
+
5
+ /**
6
+ * Build a {@link CodecLookup} populated with the Postgres-builtin codec definitions only.
7
+ *
8
+ * This is the default lookup used by `createPostgresAdapter()` and `new PostgresControlAdapter()` when called without a stack-derived lookup (e.g. from tests, or one-off scripts that don't compose a full stack).
9
+ *
10
+ * Extension codecs (e.g. `pg/vector@1` from `@prisma-next/extension-pgvector`) are intentionally NOT included here: a bare adapter cannot see extensions. Stack-composed paths (`SqlControlAdapterDescriptor.create(stack)` / `SqlRuntimeAdapterDescriptor.create(stack)`) supply the broader, extension-inclusive lookup at construction time.
11
+ */
12
+ export function createPostgresBuiltinCodecLookup(): CodecLookup {
13
+ return extractCodecLookup([
14
+ {
15
+ id: 'postgres-builtin-codecs',
16
+ types: { codecTypes: { codecDescriptors: Array.from(postgresCodecRegistry.values()) } },
17
+ },
18
+ ]);
19
+ }
@@ -1,4 +1,7 @@
1
+ import type { ContractMarkerRecord } from '@prisma-next/contract/types';
1
2
  import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
3
+ import { parseContractMarkerRow } from '@prisma-next/family-sql/verify';
4
+ import type { CodecLookup } from '@prisma-next/framework-components/codec';
2
5
  import type { ControlDriverInstance } from '@prisma-next/framework-components/control';
3
6
  import type {
4
7
  AnyQueryAst,
@@ -19,6 +22,7 @@ import type {
19
22
  import { parsePostgresDefault } from '@prisma-next/target-postgres/default-normalizer';
20
23
  import { normalizeSchemaNativeType } from '@prisma-next/target-postgres/native-type-normalizer';
21
24
  import { ifDefined } from '@prisma-next/utils/defined';
25
+ import { createPostgresBuiltinCodecLookup } from './codec-lookup';
22
26
  import { pgEnumControlHooks } from './enum-control-hooks';
23
27
  import { renderLoweredSql } from './sql-renderer';
24
28
  import type { PostgresContract } from './types';
@@ -31,6 +35,19 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
31
35
  readonly familyId = 'sql' as const;
32
36
  readonly targetId = 'postgres' as const;
33
37
 
38
+ private readonly codecLookup: CodecLookup;
39
+
40
+ /**
41
+ * @param codecLookup - Codec lookup used by the SQL renderer to resolve
42
+ * per-codec metadata at lower-time. Defaults to a Postgres-builtins-only
43
+ * lookup when omitted. Stack-aware callers
44
+ * (`SqlControlAdapterDescriptor.create(stack)`) supply
45
+ * `stack.codecLookup` so extension codecs are visible to the renderer.
46
+ */
47
+ constructor(codecLookup?: CodecLookup) {
48
+ this.codecLookup = codecLookup ?? createPostgresBuiltinCodecLookup();
49
+ }
50
+
34
51
  /**
35
52
  * Target-specific normalizer for raw Postgres default expressions.
36
53
  * Used by schema verification to normalize raw defaults before comparison.
@@ -53,7 +70,108 @@ export class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
53
70
  * without instantiating the runtime adapter.
54
71
  */
55
72
  lower(ast: AnyQueryAst, context: LowererContext<unknown>): LoweredStatement {
56
- return renderLoweredSql(ast, context.contract as PostgresContract);
73
+ return renderLoweredSql(ast, context.contract as PostgresContract, this.codecLookup);
74
+ }
75
+
76
+ /**
77
+ * Reads the contract marker from `prisma_contract.marker`. Probes
78
+ * `information_schema.tables` first so a fresh database (where the
79
+ * `prisma_contract` schema doesn't yet exist) returns `null` instead of a
80
+ * "relation does not exist" error — some Postgres wire-protocol clients
81
+ * (e.g. PGlite's TCP proxy) don't fully recover from extended-protocol
82
+ * parse errors, so we probe before reading.
83
+ */
84
+ async readMarker(
85
+ driver: ControlDriverInstance<'sql', 'postgres'>,
86
+ space: string,
87
+ ): Promise<ContractMarkerRecord | null> {
88
+ const exists = await driver.query(
89
+ `select 1
90
+ from information_schema.tables
91
+ where table_schema = $1 and table_name = $2`,
92
+ ['prisma_contract', 'marker'],
93
+ );
94
+ if (exists.rows.length === 0) {
95
+ return null;
96
+ }
97
+
98
+ const result = await driver.query<{
99
+ core_hash: string;
100
+ profile_hash: string;
101
+ contract_json: unknown | null;
102
+ canonical_version: number | null;
103
+ updated_at: Date | string;
104
+ app_tag: string | null;
105
+ meta: unknown | null;
106
+ invariants: readonly string[];
107
+ }>(
108
+ `select
109
+ core_hash,
110
+ profile_hash,
111
+ contract_json,
112
+ canonical_version,
113
+ updated_at,
114
+ app_tag,
115
+ meta,
116
+ invariants
117
+ from prisma_contract.marker
118
+ where space = $1`,
119
+ [space],
120
+ );
121
+
122
+ const row = result.rows[0];
123
+ if (!row) return null;
124
+ return parseContractMarkerRow(row);
125
+ }
126
+
127
+ /**
128
+ * Reads every row from `prisma_contract.marker` and returns them keyed
129
+ * by `space`. Mirrors the existence probe in {@link readMarker}: a
130
+ * fresh database without the `prisma_contract` schema returns an empty
131
+ * map rather than raising "relation does not exist".
132
+ */
133
+ async readAllMarkers(
134
+ driver: ControlDriverInstance<'sql', 'postgres'>,
135
+ ): Promise<ReadonlyMap<string, ContractMarkerRecord>> {
136
+ const exists = await driver.query(
137
+ `select 1
138
+ from information_schema.tables
139
+ where table_schema = $1 and table_name = $2`,
140
+ ['prisma_contract', 'marker'],
141
+ );
142
+ if (exists.rows.length === 0) {
143
+ return new Map();
144
+ }
145
+
146
+ const result = await driver.query<{
147
+ space: string;
148
+ core_hash: string;
149
+ profile_hash: string;
150
+ contract_json: unknown | null;
151
+ canonical_version: number | null;
152
+ updated_at: Date | string;
153
+ app_tag: string | null;
154
+ meta: unknown | null;
155
+ invariants: readonly string[];
156
+ }>(
157
+ `select
158
+ space,
159
+ core_hash,
160
+ profile_hash,
161
+ contract_json,
162
+ canonical_version,
163
+ updated_at,
164
+ app_tag,
165
+ meta,
166
+ invariants
167
+ from prisma_contract.marker`,
168
+ );
169
+
170
+ const rows = new Map<string, ContractMarkerRecord>();
171
+ for (const row of result.rows) {
172
+ rows.set(row.space, parseContractMarkerRow(row));
173
+ }
174
+ return rows;
57
175
  }
58
176
 
59
177
  /**
@@ -1,4 +1,5 @@
1
1
  import type { ExecutionMutationDefaultValue } from '@prisma-next/contract/types';
2
+ import { timestampNowControlDescriptor } from '@prisma-next/family-sql/control';
2
3
  import type {
3
4
  ControlMutationDefaultEntry,
4
5
  DefaultFunctionLoweringContext,
@@ -301,25 +302,30 @@ export function createPostgresDefaultFunctionRegistry(): ReadonlyMap<
301
302
  }
302
303
 
303
304
  export function createPostgresMutationDefaultGeneratorDescriptors(): readonly MutationDefaultGeneratorDescriptor[] {
304
- return builtinGeneratorRegistryMetadata.map(({ id, applicableCodecIds }) => ({
305
- id,
306
- applicableCodecIds,
307
- resolveGeneratedColumnDescriptor: ({ generated }) => {
308
- if (generated.kind !== 'generator' || generated.id !== id) {
309
- return undefined;
310
- }
311
- const descriptor = resolveBuiltinGeneratedColumnDescriptor({
305
+ return [
306
+ ...builtinGeneratorRegistryMetadata.map(
307
+ ({ id, applicableCodecIds }): MutationDefaultGeneratorDescriptor => ({
312
308
  id,
313
- ...(generated.params ? { params: generated.params } : {}),
314
- });
315
- return {
316
- codecId: descriptor.type.codecId,
317
- nativeType: descriptor.type.nativeType,
318
- ...(descriptor.type.typeRef ? { typeRef: descriptor.type.typeRef } : {}),
319
- ...(descriptor.typeParams ? { typeParams: descriptor.typeParams } : {}),
320
- };
321
- },
322
- }));
309
+ applicableCodecIds,
310
+ resolveGeneratedColumnDescriptor: ({ generated }) => {
311
+ if (generated.kind !== 'generator' || generated.id !== id) {
312
+ return undefined;
313
+ }
314
+ const descriptor = resolveBuiltinGeneratedColumnDescriptor({
315
+ id,
316
+ ...(generated.params ? { params: generated.params } : {}),
317
+ });
318
+ return {
319
+ codecId: descriptor.type.codecId,
320
+ nativeType: descriptor.type.nativeType,
321
+ ...(descriptor.type.typeRef ? { typeRef: descriptor.type.typeRef } : {}),
322
+ ...(descriptor.typeParams ? { typeParams: descriptor.typeParams } : {}),
323
+ };
324
+ },
325
+ }),
326
+ ),
327
+ timestampNowControlDescriptor(),
328
+ ];
323
329
  }
324
330
 
325
331
  export function createPostgresScalarTypeDescriptors(): ReadonlyMap<string, string> {
@@ -1,8 +1,17 @@
1
1
  import type { CodecControlHooks, ExpandNativeTypeInput } from '@prisma-next/family-sql/control';
2
2
  import type { SqlOperationDescriptor } from '@prisma-next/sql-operations';
3
+ import {
4
+ buildOperation,
5
+ type CodecExpression,
6
+ type Expression,
7
+ refsOf,
8
+ type TraitExpression,
9
+ toExpr,
10
+ } from '@prisma-next/sql-relational-core/expression';
3
11
  import {
4
12
  PG_BIT_CODEC_ID,
5
13
  PG_BOOL_CODEC_ID,
14
+ PG_BYTEA_CODEC_ID,
6
15
  PG_CHAR_CODEC_ID,
7
16
  PG_ENUM_CODEC_ID,
8
17
  PG_FLOAT_CODEC_ID,
@@ -30,12 +39,10 @@ import {
30
39
  SQL_TIMESTAMP_CODEC_ID,
31
40
  SQL_VARCHAR_CODEC_ID,
32
41
  } from '@prisma-next/target-postgres/codec-ids';
33
- import { codecDefinitions } from '@prisma-next/target-postgres/codecs';
42
+ import { postgresCodecRegistry } from '@prisma-next/target-postgres/codecs';
34
43
  import { pgEnumControlHooks } from './enum-control-hooks';
35
44
 
36
- // ============================================================================
37
- // Helper functions for reducing boilerplate
38
- // ============================================================================
45
+ // ============================================================================ Helper functions for reducing boilerplate ============================================================================
39
46
 
40
47
  /** Creates a type import spec for codec types */
41
48
  const codecTypeImport = (named: string) =>
@@ -124,21 +131,32 @@ const precisionHooks: CodecControlHooks = { expandNativeType: expandPrecision };
124
131
  const numericHooks: CodecControlHooks = { expandNativeType: expandNumeric };
125
132
  const identityHooks: CodecControlHooks = { expandNativeType: ({ nativeType }) => nativeType };
126
133
 
127
- // ============================================================================
128
- // Descriptor metadata
129
- // ============================================================================
134
+ // ============================================================================ Descriptor metadata ============================================================================
130
135
 
131
- export const postgresQueryOperations: readonly SqlOperationDescriptor[] = [
132
- {
133
- method: 'ilike',
134
- args: [
135
- { traits: ['textual'], nullable: false },
136
- { codecId: PG_TEXT_CODEC_ID, nullable: false },
137
- ],
138
- returns: { codecId: PG_BOOL_CODEC_ID, nullable: false },
139
- lowering: { targetFamily: 'sql', strategy: 'infix', template: '{{self}} ILIKE {{arg0}}' },
140
- },
141
- ];
136
+ type CodecTypesBase = Record<string, { readonly input: unknown; readonly output: unknown }>;
137
+
138
+ export function postgresQueryOperations<
139
+ CT extends CodecTypesBase,
140
+ >(): readonly SqlOperationDescriptor[] {
141
+ return [
142
+ {
143
+ method: 'ilike',
144
+ self: { traits: ['textual'] },
145
+ impl: (
146
+ self: TraitExpression<readonly ['textual'], false, CT>,
147
+ pattern: CodecExpression<'pg/text@1', false, CT>,
148
+ ): Expression<{ codecId: 'pg/bool@1'; nullable: false }> => {
149
+ const selfRefs = refsOf(self);
150
+ return buildOperation({
151
+ method: 'ilike',
152
+ args: [toExpr(self), toExpr(pattern, PG_TEXT_CODEC_ID, selfRefs)],
153
+ returns: { codecId: PG_BOOL_CODEC_ID, nullable: false },
154
+ lowering: { targetFamily: 'sql', strategy: 'infix', template: '{{self}} ILIKE {{arg0}}' },
155
+ });
156
+ },
157
+ },
158
+ ];
159
+ }
142
160
 
143
161
  export const postgresAdapterDescriptorMeta = {
144
162
  kind: 'adapter',
@@ -162,7 +180,7 @@ export const postgresAdapterDescriptorMeta = {
162
180
  },
163
181
  types: {
164
182
  codecTypes: {
165
- codecInstances: Object.values(codecDefinitions).map((def) => def.codec),
183
+ codecDescriptors: Array.from(postgresCodecRegistry.values()),
166
184
  import: {
167
185
  package: '@prisma-next/target-postgres/codec-types',
168
186
  named: 'CodecTypes',
@@ -202,6 +220,7 @@ export const postgresAdapterDescriptorMeta = {
202
220
  [PG_ENUM_CODEC_ID]: pgEnumControlHooks,
203
221
  [PG_JSON_CODEC_ID]: identityHooks,
204
222
  [PG_JSONB_CODEC_ID]: identityHooks,
223
+ [PG_BYTEA_CODEC_ID]: identityHooks,
205
224
  },
206
225
  },
207
226
  storage: [
@@ -267,6 +286,7 @@ export const postgresAdapterDescriptorMeta = {
267
286
  },
268
287
  { typeId: PG_JSON_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'json' },
269
288
  { typeId: PG_JSONB_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'jsonb' },
289
+ { typeId: PG_BYTEA_CODEC_ID, familyId: 'sql', targetId: 'postgres', nativeType: 'bytea' },
270
290
  ],
271
291
  queryOperationTypes: {
272
292
  import: {