@prisma-next/adapter-sqlite 0.12.0 → 0.13.0-dev.1
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 +9 -9
- package/dist/{adapter-Cn_t9TdZ.d.mts → adapter-CPydDe3Y.d.mts} +4 -3
- package/dist/adapter-CPydDe3Y.d.mts.map +1 -0
- package/dist/adapter-DCwhDr2I.mjs +795 -0
- package/dist/adapter-DCwhDr2I.mjs.map +1 -0
- package/dist/adapter.d.mts +1 -1
- package/dist/adapter.mjs +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/control.d.mts +56 -7
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +4 -195
- package/dist/control.mjs.map +1 -1
- package/dist/{descriptor-meta-yjlqZvLC.mjs → descriptor-meta-Du5OgSxS.mjs} +1 -1
- package/dist/{descriptor-meta-yjlqZvLC.mjs.map → descriptor-meta-Du5OgSxS.mjs.map} +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/{types-bTlW__XL.d.mts → types-rMUNtvF6.d.mts} +1 -1
- package/dist/{types-bTlW__XL.d.mts.map → types-rMUNtvF6.d.mts.map} +1 -1
- package/dist/types.d.mts +2 -2
- package/package.json +24 -24
- package/src/core/adapter.ts +79 -44
- package/src/core/control-adapter.ts +323 -118
- package/src/core/ddl-renderer.ts +123 -0
- package/src/core/ledger-decode.ts +26 -0
- package/src/core/marker-ledger.ts +124 -0
- package/dist/adapter-BOg2xl4V.mjs +0 -348
- package/dist/adapter-BOg2xl4V.mjs.map +0 -1
- package/dist/adapter-Cn_t9TdZ.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Provide SQLite-specific adapter implementation, codecs, and capabilities. Enable
|
|
|
20
20
|
|
|
21
21
|
- **Adapter Implementation**: Implement `Adapter` SPI for SQLite
|
|
22
22
|
- Lower SQL ASTs to SQLite dialect SQL
|
|
23
|
-
- Render
|
|
23
|
+
- Render JSON aggregation (`json_group_array`, `json_object`) and scalar subqueries
|
|
24
24
|
- Advertise SQLite capabilities (`jsonAgg`, `returning`; no `lateral`, no `enums`)
|
|
25
25
|
- Provide target-specific marker SQL via `readMarkerStatement()` on `AdapterProfile`
|
|
26
26
|
- Map SQLite errors to `RuntimeError` envelope
|
|
@@ -91,7 +91,7 @@ flowchart TD
|
|
|
91
91
|
- Main adapter implementation
|
|
92
92
|
- Lowers SQL ASTs to SQLite SQL with `?` positional parameters
|
|
93
93
|
- Renders joins (INNER, LEFT, RIGHT, FULL) with ON conditions
|
|
94
|
-
- Renders
|
|
94
|
+
- Renders JSON aggregation (`json_group_array`, `json_object`) and scalar subqueries
|
|
95
95
|
- Renders DML operations (INSERT, UPDATE, DELETE) with RETURNING clauses
|
|
96
96
|
- Renders ON CONFLICT (DO NOTHING / DO UPDATE SET) for upserts
|
|
97
97
|
- Uses `CAST(expr AS type)` instead of Postgres `::type` syntax
|
|
@@ -148,18 +148,18 @@ The adapter declares the following SQLite capabilities:
|
|
|
148
148
|
|
|
149
149
|
- **`sql.orderBy: true`** -- Supports ORDER BY clauses
|
|
150
150
|
- **`sql.limit: true`** -- Supports LIMIT clauses
|
|
151
|
-
- **`sql.lateral: false`** -- No LATERAL join support
|
|
152
|
-
- **`sql.jsonAgg: true`** -- Supports JSON aggregation via `json_group_array()`
|
|
151
|
+
- **`sql.lateral: false`** -- No LATERAL join support
|
|
152
|
+
- **`sql.jsonAgg: true`** -- Supports JSON aggregation via `json_group_array()`
|
|
153
153
|
- **`sql.returning: true`** -- Supports RETURNING clauses for DML operations (SQLite 3.35+)
|
|
154
154
|
- **`sql.enums: false`** -- No native enum support
|
|
155
155
|
|
|
156
|
-
##
|
|
156
|
+
## JSON Aggregation
|
|
157
157
|
|
|
158
|
-
The
|
|
158
|
+
The renderer lowers JSON-aggregation AST nodes using SQLite's `json_group_array()` and `json_object()`:
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
160
|
+
- `json_group_array(json_object(...))` inside a scalar subquery aggregates a row set into a JSON array of objects
|
|
161
|
+
- The scalar subquery correlates against the outer row through its WHERE clause
|
|
162
|
+
- `COALESCE(..., '[]')` yields an empty array when the row set is empty
|
|
163
163
|
|
|
164
164
|
**Example SQL Output:**
|
|
165
165
|
```sql
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { n as SqliteContract, r as SqliteLoweredStatement, t as SqliteAdapterOptions } from "./types-
|
|
1
|
+
import { n as SqliteContract, r as SqliteLoweredStatement, t as SqliteAdapterOptions } from "./types-rMUNtvF6.mjs";
|
|
2
2
|
import { Adapter, AdapterProfile, AnyQueryAst, LowererContext } from "@prisma-next/sql-relational-core/ast";
|
|
3
3
|
import { RawCodecInferer } from "@prisma-next/sql-relational-core/expression";
|
|
4
|
+
import { SqliteDdlNode } from "@prisma-next/target-sqlite/ddl";
|
|
4
5
|
|
|
5
6
|
//#region src/core/adapter.d.ts
|
|
6
7
|
declare class SqliteAdapterImpl implements Adapter<AnyQueryAst, SqliteContract, SqliteLoweredStatement> {
|
|
@@ -8,11 +9,11 @@ declare class SqliteAdapterImpl implements Adapter<AnyQueryAst, SqliteContract,
|
|
|
8
9
|
readonly targetId: "sqlite";
|
|
9
10
|
readonly profile: AdapterProfile<'sqlite'>;
|
|
10
11
|
constructor(options?: SqliteAdapterOptions);
|
|
11
|
-
lower(ast: AnyQueryAst, context: LowererContext<SqliteContract>): SqliteLoweredStatement;
|
|
12
|
+
lower(ast: AnyQueryAst | SqliteDdlNode, context: LowererContext<SqliteContract>): SqliteLoweredStatement;
|
|
12
13
|
}
|
|
13
14
|
/** Codec-id lookup for bare-literal interpolations used by `fns.raw` on a sqlite client. Contributed as the descriptor's static `rawCodecInferer` slot. */
|
|
14
15
|
declare const sqliteRawCodecInferer: RawCodecInferer;
|
|
15
16
|
declare function createSqliteAdapter(options?: SqliteAdapterOptions): Readonly<SqliteAdapterImpl>;
|
|
16
17
|
//#endregion
|
|
17
18
|
export { sqliteRawCodecInferer as n, createSqliteAdapter as t };
|
|
18
|
-
//# sourceMappingURL=adapter-
|
|
19
|
+
//# sourceMappingURL=adapter-CPydDe3Y.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-CPydDe3Y.d.mts","names":[],"sources":["../src/core/adapter.ts"],"mappings":";;;;;;cAqDM,iBAAA,YAA6B,OAAA,CAAQ,WAAA,EAAa,cAAA,EAAgB,sBAAA;EAAA,SAC7D,QAAA;EAAA,SACA,QAAA;EAAA,SAEA,OAAA,EAAS,cAAA;cAEN,OAAA,GAAU,oBAAA;EAyBtB,KAAA,CACE,GAAA,EAAK,WAAA,GAAc,aAAA,EACnB,OAAA,EAAS,cAAA,CAAe,cAAA,IACvB,sBAAA;AAAA;;cASQ,qBAAA,EAAuB,eAoBnC;AAAA,iBAygBe,mBAAA,CAAoB,OAAA,GAAU,oBAAA,GAAoB,QAAA,CAAA,iBAAA"}
|