@prisma-next/adapter-postgres 0.12.0-dev.4 → 0.12.0-dev.6
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.
- package/README.md +13 -20
- package/package.json +22 -22
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Provide PostgreSQL-specific adapter implementation, codecs, and capabilities. En
|
|
|
20
20
|
|
|
21
21
|
- **Adapter Implementation**: Implement `Adapter` SPI for PostgreSQL
|
|
22
22
|
- Lower SQL ASTs to PostgreSQL dialect SQL
|
|
23
|
-
- Render
|
|
23
|
+
- Render JSON aggregation (`json_agg`, `json_build_object`) and scalar subqueries
|
|
24
24
|
- Advertise PostgreSQL capabilities (`lateral`, `jsonAgg`)
|
|
25
25
|
- Normalize PostgreSQL EXPLAIN output
|
|
26
26
|
- Map PostgreSQL errors to `RuntimeError` envelope
|
|
@@ -89,8 +89,8 @@ flowchart TD
|
|
|
89
89
|
**Adapter (`adapter.ts`)**
|
|
90
90
|
- Main adapter implementation
|
|
91
91
|
- Lowers SQL ASTs to PostgreSQL SQL
|
|
92
|
-
- Renders joins (INNER, LEFT, RIGHT, FULL) with ON conditions
|
|
93
|
-
- Renders
|
|
92
|
+
- Renders joins (INNER, LEFT, RIGHT, FULL, LATERAL) with ON conditions
|
|
93
|
+
- Renders JSON aggregation (`json_agg`, `json_build_object`) and scalar subqueries
|
|
94
94
|
- Renders DML operations (INSERT, UPDATE, DELETE) with RETURNING clauses
|
|
95
95
|
- Advertises PostgreSQL capabilities (`lateral`, `jsonAgg`, `returning`)
|
|
96
96
|
- Maps PostgreSQL errors to `RuntimeError`
|
|
@@ -191,8 +191,8 @@ The adapter declares the following PostgreSQL capabilities:
|
|
|
191
191
|
|
|
192
192
|
- **`orderBy: true`** - Supports ORDER BY clauses
|
|
193
193
|
- **`limit: true`** - Supports LIMIT clauses
|
|
194
|
-
- **`lateral: true`** - Supports LATERAL joins
|
|
195
|
-
- **`jsonAgg: true`** - Supports JSON aggregation functions (`json_agg`)
|
|
194
|
+
- **`lateral: true`** - Supports LATERAL joins
|
|
195
|
+
- **`jsonAgg: true`** - Supports JSON aggregation functions (`json_agg`)
|
|
196
196
|
- **`returning: true`** - Supports RETURNING clauses for DML operations (INSERT, UPDATE, DELETE)
|
|
197
197
|
- **`sql.enums: true`** - Supports contract-defined enum storage types
|
|
198
198
|
|
|
@@ -205,29 +205,22 @@ The capabilities on the descriptor must match the capabilities in code. If they
|
|
|
205
205
|
|
|
206
206
|
See `docs/reference/capabilities.md` and `docs/architecture docs/subsystems/5. Adapters & Targets.md` for details.
|
|
207
207
|
|
|
208
|
-
##
|
|
208
|
+
## JSON Aggregation
|
|
209
209
|
|
|
210
|
-
The
|
|
210
|
+
The renderer lowers JSON-aggregation AST nodes to PostgreSQL's `json_agg`:
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
-
|
|
214
|
-
-
|
|
215
|
-
- When both `ORDER BY` and `LIMIT` are present, wraps the query in an inner SELECT that projects individual columns with aliases, then uses `json_agg(row_to_json(sub.*))` on the result
|
|
216
|
-
- Uses different aliases for the table (`{alias}_lateral`) and column (`{alias}`) to avoid ambiguity
|
|
217
|
-
|
|
218
|
-
**Capabilities Required:**
|
|
219
|
-
- `lateral: true` - Enables LATERAL join support
|
|
220
|
-
- `jsonAgg: true` - Enables `json_agg` function support
|
|
212
|
+
- `json_agg(json_build_object(...))` aggregates a row set into a JSON array of objects
|
|
213
|
+
- A scalar subquery (`SubqueryExpr`) in the SELECT list correlates against the outer row through its WHERE clause
|
|
214
|
+
- When the subquery carries an inner `ORDER BY` and `LIMIT`, its rows are wrapped in an inner SELECT, then aggregated with `json_agg(row_to_json(sub.*))`
|
|
221
215
|
|
|
222
216
|
**Example SQL Output:**
|
|
223
217
|
```sql
|
|
224
|
-
SELECT "user"."id" AS "id",
|
|
225
|
-
FROM "user"
|
|
226
|
-
LEFT JOIN LATERAL (
|
|
218
|
+
SELECT "user"."id" AS "id", (
|
|
227
219
|
SELECT json_agg(json_build_object('id', "post"."id", 'title', "post"."title")) AS "posts"
|
|
228
220
|
FROM "post"
|
|
229
221
|
WHERE "user"."id" = "post"."userId"
|
|
230
|
-
) AS "
|
|
222
|
+
) AS "posts"
|
|
223
|
+
FROM "user"
|
|
231
224
|
```
|
|
232
225
|
|
|
233
226
|
## DML Operations with RETURNING
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/adapter-postgres",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/contract": "0.12.0-dev.
|
|
9
|
-
"@prisma-next/contract-authoring": "0.12.0-dev.
|
|
10
|
-
"@prisma-next/errors": "0.12.0-dev.
|
|
11
|
-
"@prisma-next/family-sql": "0.12.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.12.0-dev.
|
|
13
|
-
"@prisma-next/ids": "0.12.0-dev.
|
|
14
|
-
"@prisma-next/sql-contract": "0.12.0-dev.
|
|
15
|
-
"@prisma-next/sql-contract-psl": "0.12.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract-ts": "0.12.0-dev.
|
|
17
|
-
"@prisma-next/sql-operations": "0.12.0-dev.
|
|
18
|
-
"@prisma-next/sql-relational-core": "0.12.0-dev.
|
|
19
|
-
"@prisma-next/sql-runtime": "0.12.0-dev.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.12.0-dev.
|
|
21
|
-
"@prisma-next/target-postgres": "0.12.0-dev.
|
|
22
|
-
"@prisma-next/utils": "0.12.0-dev.
|
|
8
|
+
"@prisma-next/contract": "0.12.0-dev.6",
|
|
9
|
+
"@prisma-next/contract-authoring": "0.12.0-dev.6",
|
|
10
|
+
"@prisma-next/errors": "0.12.0-dev.6",
|
|
11
|
+
"@prisma-next/family-sql": "0.12.0-dev.6",
|
|
12
|
+
"@prisma-next/framework-components": "0.12.0-dev.6",
|
|
13
|
+
"@prisma-next/ids": "0.12.0-dev.6",
|
|
14
|
+
"@prisma-next/sql-contract": "0.12.0-dev.6",
|
|
15
|
+
"@prisma-next/sql-contract-psl": "0.12.0-dev.6",
|
|
16
|
+
"@prisma-next/sql-contract-ts": "0.12.0-dev.6",
|
|
17
|
+
"@prisma-next/sql-operations": "0.12.0-dev.6",
|
|
18
|
+
"@prisma-next/sql-relational-core": "0.12.0-dev.6",
|
|
19
|
+
"@prisma-next/sql-runtime": "0.12.0-dev.6",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.12.0-dev.6",
|
|
21
|
+
"@prisma-next/target-postgres": "0.12.0-dev.6",
|
|
22
|
+
"@prisma-next/utils": "0.12.0-dev.6",
|
|
23
23
|
"arktype": "^2.2.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@prisma-next/cli": "0.12.0-dev.
|
|
27
|
-
"@prisma-next/driver-postgres": "0.12.0-dev.
|
|
28
|
-
"@prisma-next/migration-tools": "0.12.0-dev.
|
|
29
|
-
"@prisma-next/test-utils": "0.12.0-dev.
|
|
30
|
-
"@prisma-next/tsconfig": "0.12.0-dev.
|
|
31
|
-
"@prisma-next/tsdown": "0.12.0-dev.
|
|
26
|
+
"@prisma-next/cli": "0.12.0-dev.6",
|
|
27
|
+
"@prisma-next/driver-postgres": "0.12.0-dev.6",
|
|
28
|
+
"@prisma-next/migration-tools": "0.12.0-dev.6",
|
|
29
|
+
"@prisma-next/test-utils": "0.12.0-dev.6",
|
|
30
|
+
"@prisma-next/tsconfig": "0.12.0-dev.6",
|
|
31
|
+
"@prisma-next/tsdown": "0.12.0-dev.6",
|
|
32
32
|
"pathe": "^2.0.3",
|
|
33
33
|
"tsdown": "0.22.0",
|
|
34
34
|
"typescript": "5.9.3",
|