uql-orm 0.109.0 → 0.109.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.
|
@@ -679,6 +679,8 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
|
|
|
679
679
|
}): string;
|
|
680
680
|
/** `value`, or the one stored at `slot` where it is NULL. */
|
|
681
681
|
protected jsonOrStored(slot: JsonSlot, value: string): string;
|
|
682
|
+
/** A subquery answering a JSON value, as an operand of a JSON function. */
|
|
683
|
+
protected jsonSubquery(select: string): string;
|
|
682
684
|
/** The elements of `slot` no pulled item equals, as one array, or NULL where none is left. */
|
|
683
685
|
protected jsonKept(ctx: QueryContext, slot: JsonSlot, items: readonly unknown[]): string;
|
|
684
686
|
/** The one row per element of `slot` a pull reads, each as {@link JSON_PULL_ALIAS}. */
|
|
@@ -1830,7 +1830,7 @@ export class AbstractSqlDialect extends VectorSqlDialect {
|
|
|
1830
1830
|
jsonArrayWrite(ctx, slot, { pulls, appends }) {
|
|
1831
1831
|
const isArray = this.jsonIs(slot, 'array');
|
|
1832
1832
|
const kept = pulls.length > 0
|
|
1833
|
-
? `COALESCE(
|
|
1833
|
+
? `COALESCE(${this.jsonSubquery(this.jsonKept(ctx, slot, pulls))}, ${this.jsonEmptyArray})`
|
|
1834
1834
|
: this.jsonValue(slot);
|
|
1835
1835
|
if (appends.length === 0) {
|
|
1836
1836
|
return `CASE WHEN ${isArray} THEN ${kept} END`;
|
|
@@ -1851,6 +1851,10 @@ export class AbstractSqlDialect extends VectorSqlDialect {
|
|
|
1851
1851
|
jsonOrStored(slot, value) {
|
|
1852
1852
|
return `COALESCE(${value}, ${this.jsonValue(slot)})`;
|
|
1853
1853
|
}
|
|
1854
|
+
/** A subquery answering a JSON value, as an operand of a JSON function. */
|
|
1855
|
+
jsonSubquery(select) {
|
|
1856
|
+
return `(${select})`;
|
|
1857
|
+
}
|
|
1854
1858
|
/** The elements of `slot` no pulled item equals, as one array, or NULL where none is left. */
|
|
1855
1859
|
jsonKept(ctx, slot, items) {
|
|
1856
1860
|
return `SELECT ${this.jsonKeptAggregate(slot)} FROM ${this.jsonKeptFrom(slot)} WHERE ${this.jsonEqualsNone(ctx, slot, items)}`;
|
|
@@ -85,6 +85,8 @@ export declare class SqliteDialect extends AbstractSqlDialect {
|
|
|
85
85
|
protected jsonPathReading(escapedColumn: string, path: string, mode: 'json' | 'text'): string;
|
|
86
86
|
protected numericCast(expr: string): string;
|
|
87
87
|
protected jsonCast(operand: string): string;
|
|
88
|
+
/** Read through {@link jsonCast}: a scalar subquery's value loses its JSON subtype at its edge on SQLite 3.54+. */
|
|
89
|
+
protected jsonSubquery(select: string): string;
|
|
88
90
|
/** `JSON` keeps each element's JSON type in the array, which answers `[]` for no rows. */
|
|
89
91
|
protected jsonArrayOf(elem: string): string;
|
|
90
92
|
protected jsonAppended(ctx: QueryContext, array: string, value: unknown, unless?: string): string;
|
|
@@ -222,6 +222,10 @@ export class SqliteDialect extends AbstractSqlDialect {
|
|
|
222
222
|
jsonCast(operand) {
|
|
223
223
|
return `JSON(${operand})`;
|
|
224
224
|
}
|
|
225
|
+
/** Read through {@link jsonCast}: a scalar subquery's value loses its JSON subtype at its edge on SQLite 3.54+. */
|
|
226
|
+
jsonSubquery(select) {
|
|
227
|
+
return this.jsonCast(`(${select})`);
|
|
228
|
+
}
|
|
225
229
|
/** `JSON` keeps each element's JSON type in the array, which answers `[]` for no rows. */
|
|
226
230
|
jsonArrayOf(elem) {
|
|
227
231
|
return `JSON_GROUP_ARRAY(JSON(${elem}))`;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
4
|
"description": "JSON-native TypeScript ORM for Bun, Browsers, Edge, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.109.
|
|
6
|
+
"version": "0.109.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=22.18"
|