@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 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 `includeMany` as correlated subquery with `json_group_array(json_object(...))` for nested array includes
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 `includeMany` as correlated subquery with `json_group_array(json_object(...))` for nested array includes
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; `includeMany` uses correlated subquery fallback
152
- - **`sql.jsonAgg: true`** -- Supports JSON aggregation via `json_group_array()` for `includeMany`
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
- ## includeMany Support
156
+ ## JSON Aggregation
157
157
 
158
- The adapter supports `includeMany` for nested array includes using SQLite's `json_group_array()` and `json_object()`:
158
+ The renderer lowers JSON-aggregation AST nodes using SQLite's `json_group_array()` and `json_object()`:
159
159
 
160
- **Lowering Strategy:**
161
- - Renders `includeMany` as a correlated subquery with `json_group_array(json_object(...))` to aggregate child rows into a JSON array
162
- - Uses `COALESCE(..., '[]')` to handle empty results
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-bTlW__XL.mjs";
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-Cn_t9TdZ.d.mts.map
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"}