uql-orm 0.100.1 → 0.100.3
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 +8 -70
- package/dist/browser/uql-browser.min.js.map +1 -1
- package/dist/bunSql/bunSqlQuerierPool.js +3 -1
- package/dist/dialect/abstractSqlDialect.d.ts +32 -22
- package/dist/dialect/abstractSqlDialect.js +65 -59
- package/dist/dialect/hydrateColumn.d.ts +4 -5
- package/dist/dialect/hydrateColumn.js +2 -8
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +4 -4
- package/dist/dialect/mysqlLikeSqlDialect.js +7 -6
- package/dist/dialect/pgLikeSqlDialect.d.ts +8 -2
- package/dist/dialect/pgLikeSqlDialect.js +11 -3
- package/dist/http/fetchHandler.d.ts +1 -1
- package/dist/http/fetchHandler.js +1 -1
- package/dist/mariadb/mariaDialect.d.ts +2 -2
- package/dist/mariadb/mariaDialect.js +1 -0
- package/dist/migrate/cli-config.d.ts +2 -4
- package/dist/migrate/cli-config.js +4 -4
- package/dist/migrate/codegen/migrationFile.d.ts +1 -4
- package/dist/migrate/codegen/migrationFile.js +3 -5
- package/dist/migrate/codegen/sourceLiteral.d.ts +5 -3
- package/dist/migrate/codegen/sourceLiteral.js +8 -5
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +1 -3
- package/dist/mongodb/mongoDialect.js +9 -7
- package/dist/mssql/mssqlDialect.d.ts +2 -2
- package/dist/mssql/mssqlDialect.js +1 -0
- package/dist/pglite/pgliteQuerierPool.js +6 -12
- package/dist/postgres/abstractPgQuerierPool.d.ts +0 -1
- package/dist/postgres/abstractPgQuerierPool.js +0 -3
- package/dist/postgres/pgQuerier.d.ts +6 -0
- package/dist/postgres/pgQuerier.js +10 -0
- package/dist/postgres/pgWireTypes.d.ts +11 -7
- package/dist/postgres/pgWireTypes.js +47 -11
- package/dist/querier/abstractPoolQuerier.d.ts +2 -0
- package/dist/querier/abstractPoolQuerier.js +5 -1
- package/dist/querier/abstractQuerier.d.ts +1 -5
- package/dist/querier/abstractQuerier.js +18 -17
- package/dist/querier/abstractSqlQuerier.d.ts +6 -20
- package/dist/querier/abstractSqlQuerier.js +27 -94
- package/dist/querier/abstractSqlQuerierPool.d.ts +3 -5
- package/dist/querier/abstractSqlQuerierPool.js +2 -5
- package/dist/querier/rowReader.d.ts +8 -0
- package/dist/querier/rowReader.js +88 -0
- package/dist/sqlite/sqliteDialect.d.ts +2 -2
- package/dist/sqlite/sqliteDialect.js +2 -1
- package/dist/type/querier.d.ts +3 -5
- package/dist/type/queryRaw.d.ts +4 -1
- package/dist/type/queryRaw.js +2 -2
- package/dist/util/dialect.util.d.ts +2 -11
- package/dist/util/dialect.util.js +8 -21
- package/dist/util/query.util.js +16 -8
- package/dist/util/raw.js +19 -16
- package/dist/util/sql.util.d.ts +0 -5
- package/dist/util/sql.util.js +0 -33
- package/dist/util/wideNumber.d.ts +4 -3
- package/dist/util/wideNumber.js +17 -6
- package/package.json +3 -4
- package/skills/uql-orm/SKILL.md +2 -2
|
@@ -7,9 +7,10 @@ import type { RawRow } from '../type/index.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function decodeWideNumber(value: string | bigint): number | string;
|
|
9
9
|
/**
|
|
10
|
-
* {@link decodeWideNumber} over every `bigint` cell of a row,
|
|
11
|
-
* one (`bun:sql`, `mariadb`, and every SQLite driver but D1). In
|
|
12
|
-
* object, and a copy per row cost more than the decode it carried.
|
|
10
|
+
* {@link decodeWideNumber} over every `bigint` cell of a row, an array's elements included, for the
|
|
11
|
+
* drivers that hand a BIGINT back as one (`bun:sql`, `mariadb`, and every SQLite driver but D1). In
|
|
12
|
+
* place: the row is the driver's fresh object, and a copy per row cost more than the decode it carried.
|
|
13
|
+
* One argument, so it maps rows as is.
|
|
13
14
|
*/
|
|
14
15
|
export declare function decodeBigInts(row: RawRow): RawRow;
|
|
15
16
|
/** {@link decodeBigInts}, keeping the cells `exact` names: what MongoDB reads a `BigInt` field into. */
|
package/dist/util/wideNumber.js
CHANGED
|
@@ -9,9 +9,10 @@ export function decodeWideNumber(value) {
|
|
|
9
9
|
return Math.abs(decoded) <= Number.MAX_SAFE_INTEGER ? decoded : String(value);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* {@link decodeWideNumber} over every `bigint` cell of a row,
|
|
13
|
-
* one (`bun:sql`, `mariadb`, and every SQLite driver but D1). In
|
|
14
|
-
* object, and a copy per row cost more than the decode it carried.
|
|
12
|
+
* {@link decodeWideNumber} over every `bigint` cell of a row, an array's elements included, for the
|
|
13
|
+
* drivers that hand a BIGINT back as one (`bun:sql`, `mariadb`, and every SQLite driver but D1). In
|
|
14
|
+
* place: the row is the driver's fresh object, and a copy per row cost more than the decode it carried.
|
|
15
|
+
* One argument, so it maps rows as is.
|
|
15
16
|
*/
|
|
16
17
|
export function decodeBigInts(row) {
|
|
17
18
|
return decodeBigIntsExcept(row, () => false);
|
|
@@ -19,10 +20,20 @@ export function decodeBigInts(row) {
|
|
|
19
20
|
/** {@link decodeBigInts}, keeping the cells `exact` names: what MongoDB reads a `BigInt` field into. */
|
|
20
21
|
export function decodeBigIntsExcept(row, exact) {
|
|
21
22
|
for (const key in row) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
row[key] = decodeWideNumber(value);
|
|
23
|
+
if (!exact(key)) {
|
|
24
|
+
row[key] = decodeBigIntsIn(row[key]);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return row;
|
|
28
28
|
}
|
|
29
|
+
function decodeBigIntsIn(value) {
|
|
30
|
+
if (typeof value === 'bigint') {
|
|
31
|
+
return decodeWideNumber(value);
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
value.forEach((element, index) => {
|
|
35
|
+
value[index] = decodeBigIntsIn(element);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uql-orm",
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
|
-
"description": "JSON-native TypeScript ORM for Bun, Browsers, Edge,
|
|
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.100.
|
|
6
|
+
"version": "0.100.3",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"@types/pg": "^8.23.1",
|
|
142
142
|
"@types/ws": "^8.18.2",
|
|
143
143
|
"better-sqlite3": "^13.0.3",
|
|
144
|
-
"express": "^5.
|
|
144
|
+
"express": "^5.3.0",
|
|
145
145
|
"mariadb": "^3.5.4",
|
|
146
146
|
"mongodb": "^7.7.0",
|
|
147
147
|
"mssql": "^12.7.4",
|
|
@@ -196,7 +196,6 @@
|
|
|
196
196
|
"d1",
|
|
197
197
|
"cloudflare",
|
|
198
198
|
"bun",
|
|
199
|
-
"deno",
|
|
200
199
|
"node",
|
|
201
200
|
"nodejs",
|
|
202
201
|
"edge",
|
package/skills/uql-orm/SKILL.md
CHANGED
|
@@ -20,7 +20,7 @@ The full docs are Markdown at https://uql-orm.dev/llms.txt, one page per URL. Re
|
|
|
20
20
|
npm install uql-orm pg # or mysql2, mariadb, better-sqlite3, mongodb, @libsql/client, ...
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
ESM only. Node 24+, Bun
|
|
23
|
+
ESM only. Node 24+, Bun or an edge runtime, TypeScript 5.7+. Decorators are the TC39 standard: never enable `experimentalDecorators` or `emitDecoratorMetadata`, never import `reflect-metadata`. In `tsconfig.json`, `module` is `nodenext` or `preserve`, and `target` is a dated one (`es2022`+), not `esnext`.
|
|
24
24
|
|
|
25
25
|
Node's type stripping runs no decorators: on Node, add `tsx` (`npm i -D tsx`), which `uql-migrate` imports `uql.config.ts` through. Next.js compiles TC39 decorators only through a `babel.config.json` with `@babel/plugin-proposal-decorators` at `version: '2023-11'`. A bundle that minifies class names (Next's server build, or any bundler's `minify`) needs `@Entity({ name: 'todo' })`: a table name is the class name otherwise.
|
|
26
26
|
|
|
@@ -118,7 +118,7 @@ const users = await pool.findMany(User, {
|
|
|
118
118
|
- An update takes `{ stock: { $inc: -1 } }` to add, or `$mul` to multiply, in the statement, a NULL counting as 0, so a guard in `$where` (`stock: { $gte: 1 }`) makes a decrement race-safe. On SQL the step may be a ref or `raw` of the field's type (`{ total: { $inc: newRow.amount } }` in a trigger). JSON fields take `$set`, `$unset`, `$push`, `$pull`.
|
|
119
119
|
- `$lock: true` locks the rows a read returns (`{ $wait: 'skip' | 'nowait' }` says what to do about a row someone else holds) and needs an open transaction; SQLite, libSQL, Turso, D1 and MongoDB have no row lock and refuse it.
|
|
120
120
|
- `queryErrorKind(err)` names any failure the same on every engine - `uniqueViolation`, `foreignKeyViolation`, `notNullViolation`, `checkViolation`, `optimisticLock`, `retryable`, `usage`, `security` - so catch by kind rather than by a driver's code or an `instanceof`. Every error UQL raises itself is a `UqlError`.
|
|
121
|
-
- ``pool.all`SELECT ... WHERE id = ${id}` `` runs a `SELECT` and ``pool.run`...` `` a write: both are tags, each interpolated value bound: a scalar, `null` or a list of them, never `undefined` or a plain object (bind `JSON.stringify(doc)`). `raw` builds a fragment to embed anywhere a value or field goes, or to compose a statement, and `raw.join(fragments, ' AND ')` joins them. `raw.text(sql)` runs trusted SQL held in a string, binding nothing: never build it from user input. Migrations write ``querier.run`CREATE TABLE ...` ``. `raw` is a tag, so ``raw(`...`)`` does not compile. A field read off `refs(Entity)` carries its type: on its own as a value it fits only a field of that type.
|
|
121
|
+
- ``pool.all`SELECT ... WHERE id = ${id}` `` runs a `SELECT` and ``pool.run`...` `` a write, one statement per call: both are tags, each interpolated value bound: a scalar, `null` or a list of them, never `undefined` or a plain object (bind `JSON.stringify(doc)`). `raw` builds a fragment to embed anywhere a value or field goes, or to compose a statement, and `raw.join(fragments, ' AND ')` joins them. `raw.text(sql)` runs trusted SQL held in a string, binding nothing: never build it from user input. Migrations write ``querier.run`CREATE TABLE ...` ``. `raw` is a tag, so ``raw(`...`)`` does not compile. A field read off `refs(Entity)` carries its type: on its own as a value it fits only a field of that type.
|
|
122
122
|
|
|
123
123
|
## Connections and transactions
|
|
124
124
|
|