metal-orm 1.0.62 → 1.0.64
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 +10 -8
- package/dist/index.cjs +187 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +844 -422
- package/dist/index.d.ts +844 -422
- package/dist/index.js +184 -119
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/ast/aggregate-functions.ts +13 -4
- package/src/core/ast/expression-builders.ts +325 -111
- package/src/core/ast/expression.ts +9 -0
- package/src/core/ast/window-functions.ts +62 -52
- package/src/core/functions/array.ts +12 -3
- package/src/core/functions/control-flow.ts +28 -18
- package/src/core/functions/datetime.ts +113 -84
- package/src/core/functions/json.ts +40 -8
- package/src/core/functions/numeric.ts +116 -79
- package/src/core/functions/text.ts +181 -114
- package/src/decorators/bootstrap.ts +23 -19
- package/src/query-builder/hydration-planner.ts +14 -16
- package/src/query-builder/select.ts +91 -55
package/README.md
CHANGED
|
@@ -549,14 +549,16 @@ const [user] = await selectFromEntity(User)
|
|
|
549
549
|
.where(eq(U.id, 1))
|
|
550
550
|
.execute(session); // user is an actual instance of the User class!
|
|
551
551
|
|
|
552
|
-
// Use executePlain() if you want raw POJOs instead of class instances
|
|
553
|
-
const [rawUser] = await selectFromEntity(User).executePlain(session);
|
|
554
|
-
|
|
555
|
-
user.posts.add({ title: 'From decorators' });
|
|
556
|
-
await session.commit();
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
|
|
552
|
+
// Use executePlain() if you want raw POJOs instead of class instances
|
|
553
|
+
const [rawUser] = await selectFromEntity(User).executePlain(session);
|
|
554
|
+
|
|
555
|
+
user.posts.add({ title: 'From decorators' });
|
|
556
|
+
await session.commit();
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Note: relation helpers like `add`/`attach` are only available on tracked entities returned by `execute(session)`. `executePlain()` returns POJOs without relation wrappers. Make sure the primary key (e.g. `id`) is selected so relation adds can link correctly.
|
|
560
|
+
|
|
561
|
+
Tip: to keep selections terse, use `select`, `include` (with `columns`), or the `sel`/`esel` helpers instead of spelling `table.columns.*` over and over. By default, `selectFromEntity` selects all columns if you don't specify any.
|
|
560
562
|
|
|
561
563
|
|
|
562
564
|
This level is nice when:
|
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,7 @@ __export(index_exports, {
|
|
|
81
81
|
aliasRef: () => aliasRef,
|
|
82
82
|
and: () => and,
|
|
83
83
|
arrayAppend: () => arrayAppend,
|
|
84
|
+
asType: () => asType,
|
|
84
85
|
ascii: () => ascii,
|
|
85
86
|
asin: () => asin,
|
|
86
87
|
atan: () => atan,
|
|
@@ -146,6 +147,8 @@ __export(index_exports, {
|
|
|
146
147
|
eq: () => eq,
|
|
147
148
|
esel: () => esel,
|
|
148
149
|
executeHydrated: () => executeHydrated,
|
|
150
|
+
executeHydratedPlain: () => executeHydratedPlain,
|
|
151
|
+
executeHydratedPlainWithContexts: () => executeHydratedPlainWithContexts,
|
|
149
152
|
executeHydratedWithContexts: () => executeHydratedWithContexts,
|
|
150
153
|
executeSchemaSql: () => executeSchemaSql,
|
|
151
154
|
executeSchemaSqlFor: () => executeSchemaSqlFor,
|
|
@@ -718,12 +721,24 @@ var createBinaryExpression = (operator, left2, right2, escape) => {
|
|
|
718
721
|
}
|
|
719
722
|
return node;
|
|
720
723
|
};
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
724
|
+
function eq(left2, right2) {
|
|
725
|
+
return createBinaryExpression("=", left2, right2);
|
|
726
|
+
}
|
|
727
|
+
function neq(left2, right2) {
|
|
728
|
+
return createBinaryExpression("!=", left2, right2);
|
|
729
|
+
}
|
|
730
|
+
function gt(left2, right2) {
|
|
731
|
+
return createBinaryExpression(">", left2, right2);
|
|
732
|
+
}
|
|
733
|
+
function gte(left2, right2) {
|
|
734
|
+
return createBinaryExpression(">=", left2, right2);
|
|
735
|
+
}
|
|
736
|
+
function lt(left2, right2) {
|
|
737
|
+
return createBinaryExpression("<", left2, right2);
|
|
738
|
+
}
|
|
739
|
+
function lte(left2, right2) {
|
|
740
|
+
return createBinaryExpression("<=", left2, right2);
|
|
741
|
+
}
|
|
727
742
|
var like = (left2, pattern, escape) => createBinaryExpression("LIKE", left2, pattern, escape);
|
|
728
743
|
var notLike = (left2, pattern, escape) => createBinaryExpression("NOT LIKE", left2, pattern, escape);
|
|
729
744
|
var and = (...operands) => ({
|
|
@@ -833,7 +848,7 @@ var buildWindowFunction = (name, args = [], partitionBy, orderBy) => {
|
|
|
833
848
|
if (orderBy && orderBy.length) {
|
|
834
849
|
node.orderBy = orderBy;
|
|
835
850
|
}
|
|
836
|
-
return node;
|
|
851
|
+
return asType(node);
|
|
837
852
|
};
|
|
838
853
|
var rowNumber = () => buildWindowFunction("ROW_NUMBER");
|
|
839
854
|
var rank = () => buildWindowFunction("RANK");
|
|
@@ -937,7 +952,7 @@ var ORDER_DIRECTIONS = {
|
|
|
937
952
|
};
|
|
938
953
|
|
|
939
954
|
// src/core/ast/aggregate-functions.ts
|
|
940
|
-
var buildAggregate = (name) => (col2) => ({
|
|
955
|
+
var buildAggregate = (name) => (col2) => asType({
|
|
941
956
|
type: "Function",
|
|
942
957
|
name,
|
|
943
958
|
args: [columnOperand(col2)]
|
|
@@ -947,7 +962,7 @@ var sum = buildAggregate("SUM");
|
|
|
947
962
|
var avg = buildAggregate("AVG");
|
|
948
963
|
var min = buildAggregate("MIN");
|
|
949
964
|
var max = buildAggregate("MAX");
|
|
950
|
-
var countAll = () => ({
|
|
965
|
+
var countAll = () => asType({
|
|
951
966
|
type: "Function",
|
|
952
967
|
name: "COUNT",
|
|
953
968
|
args: []
|
|
@@ -957,7 +972,7 @@ var toOrderByNode = (order) => ({
|
|
|
957
972
|
term: columnOperand(order.column),
|
|
958
973
|
direction: order.direction ?? ORDER_DIRECTIONS.ASC
|
|
959
974
|
});
|
|
960
|
-
var groupConcat = (col2, options) => ({
|
|
975
|
+
var groupConcat = (col2, options) => asType({
|
|
961
976
|
type: "Function",
|
|
962
977
|
name: "GROUP_CONCAT",
|
|
963
978
|
args: [columnOperand(col2)],
|
|
@@ -1103,6 +1118,9 @@ var toTableRef = (table) => ({
|
|
|
1103
1118
|
alias: hasAlias(table) ? table.alias : void 0
|
|
1104
1119
|
});
|
|
1105
1120
|
|
|
1121
|
+
// src/core/ast/expression.ts
|
|
1122
|
+
var asType = (expr) => expr;
|
|
1123
|
+
|
|
1106
1124
|
// src/core/functions/function-registry.ts
|
|
1107
1125
|
var FunctionRegistry = class {
|
|
1108
1126
|
renderers = /* @__PURE__ */ new Map();
|
|
@@ -3716,10 +3734,9 @@ var HydrationPlanner = class _HydrationPlanner {
|
|
|
3716
3734
|
const rootCols = new Set(currentPlan.rootColumns);
|
|
3717
3735
|
let changed = false;
|
|
3718
3736
|
columns.forEach((node) => {
|
|
3719
|
-
|
|
3720
|
-
if (
|
|
3721
|
-
|
|
3722
|
-
if (isRelationAlias(alias)) return;
|
|
3737
|
+
const alias = node.type === "Column" ? node.alias || node.name : node.alias;
|
|
3738
|
+
if (!alias || isRelationAlias(alias)) return;
|
|
3739
|
+
if (node.type === "Column" && node.table !== this.table.name) return;
|
|
3723
3740
|
if (!rootCols.has(alias)) {
|
|
3724
3741
|
rootCols.add(alias);
|
|
3725
3742
|
changed = true;
|
|
@@ -6185,9 +6202,22 @@ var executeWithContexts = async (execCtx, entityCtx, qb) => {
|
|
|
6185
6202
|
await loadLazyRelationsForTable(entityCtx, qb.getTable(), lazyRelations, lazyRelationOptions);
|
|
6186
6203
|
return entities;
|
|
6187
6204
|
};
|
|
6205
|
+
var executePlainWithContexts = async (execCtx, qb) => {
|
|
6206
|
+
const ast = qb.getAST();
|
|
6207
|
+
const compiled = execCtx.dialect.compileSelect(ast);
|
|
6208
|
+
const executed = await execCtx.interceptors.run({ sql: compiled.sql, params: compiled.params }, execCtx.executor);
|
|
6209
|
+
const rows = flattenResults(executed);
|
|
6210
|
+
if (ast.setOps && ast.setOps.length > 0) {
|
|
6211
|
+
return rows;
|
|
6212
|
+
}
|
|
6213
|
+
return hydrateRows(rows, qb.getHydrationPlan());
|
|
6214
|
+
};
|
|
6188
6215
|
async function executeHydrated(session, qb) {
|
|
6189
6216
|
return executeWithContexts(session.getExecutionContext(), session, qb);
|
|
6190
6217
|
}
|
|
6218
|
+
async function executeHydratedPlain(session, qb) {
|
|
6219
|
+
return executePlainWithContexts(session.getExecutionContext(), qb);
|
|
6220
|
+
}
|
|
6191
6221
|
async function executeHydratedWithContexts(execCtx, hydCtx, qb) {
|
|
6192
6222
|
const entityCtx = hydCtx.entityContext;
|
|
6193
6223
|
if (!entityCtx) {
|
|
@@ -6195,6 +6225,9 @@ async function executeHydratedWithContexts(execCtx, hydCtx, qb) {
|
|
|
6195
6225
|
}
|
|
6196
6226
|
return executeWithContexts(execCtx, entityCtx, qb);
|
|
6197
6227
|
}
|
|
6228
|
+
async function executeHydratedPlainWithContexts(execCtx, qb) {
|
|
6229
|
+
return executePlainWithContexts(execCtx, qb);
|
|
6230
|
+
}
|
|
6198
6231
|
var loadLazyRelationsForTable = async (ctx, table, lazyRelations, lazyRelationOptions) => {
|
|
6199
6232
|
if (!lazyRelations.length) return;
|
|
6200
6233
|
const tracked = ctx.getEntitiesForTable(table);
|
|
@@ -6328,8 +6361,11 @@ var DefaultEntityMaterializer = class {
|
|
|
6328
6361
|
this.strategy = strategy;
|
|
6329
6362
|
}
|
|
6330
6363
|
materialize(ctor, row) {
|
|
6364
|
+
if (hasEntityMeta(row)) {
|
|
6365
|
+
return this.materializeEntityProxy(ctor, row);
|
|
6366
|
+
}
|
|
6331
6367
|
const instance = this.strategy.materialize(ctor, row);
|
|
6332
|
-
this.materializeRelations(instance
|
|
6368
|
+
this.materializeRelations(instance);
|
|
6333
6369
|
return instance;
|
|
6334
6370
|
}
|
|
6335
6371
|
materializeMany(ctor, rows) {
|
|
@@ -6338,9 +6374,9 @@ var DefaultEntityMaterializer = class {
|
|
|
6338
6374
|
/**
|
|
6339
6375
|
* Recursively materializes nested relation data.
|
|
6340
6376
|
*/
|
|
6341
|
-
materializeRelations(instance
|
|
6377
|
+
materializeRelations(instance) {
|
|
6342
6378
|
rebuildRegistry();
|
|
6343
|
-
for (const
|
|
6379
|
+
for (const value of Object.values(instance)) {
|
|
6344
6380
|
if (value === null || value === void 0) continue;
|
|
6345
6381
|
if (typeof value === "object" && !Array.isArray(value)) {
|
|
6346
6382
|
const nested = value;
|
|
@@ -6362,6 +6398,17 @@ var DefaultEntityMaterializer = class {
|
|
|
6362
6398
|
(k) => k.endsWith("Id") || k === "createdAt" || k === "updatedAt"
|
|
6363
6399
|
);
|
|
6364
6400
|
}
|
|
6401
|
+
materializeEntityProxy(ctor, row) {
|
|
6402
|
+
const proxy = row;
|
|
6403
|
+
const baseline = this.strategy.materialize(ctor, {});
|
|
6404
|
+
for (const key of Object.keys(baseline)) {
|
|
6405
|
+
if (!Object.prototype.hasOwnProperty.call(proxy, key)) {
|
|
6406
|
+
proxy[key] = baseline[key];
|
|
6407
|
+
}
|
|
6408
|
+
}
|
|
6409
|
+
Object.setPrototypeOf(proxy, ctor.prototype);
|
|
6410
|
+
return proxy;
|
|
6411
|
+
}
|
|
6365
6412
|
};
|
|
6366
6413
|
var materializeAs = (ctor, results) => {
|
|
6367
6414
|
const materializer = new DefaultEntityMaterializer();
|
|
@@ -6871,7 +6918,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6871
6918
|
select(...args) {
|
|
6872
6919
|
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && typeof args[0] !== "string") {
|
|
6873
6920
|
const columns = args[0];
|
|
6874
|
-
return this.clone(
|
|
6921
|
+
return this.clone(
|
|
6922
|
+
this.projectionFacet.select(this.context, columns)
|
|
6923
|
+
);
|
|
6875
6924
|
}
|
|
6876
6925
|
const cols = args;
|
|
6877
6926
|
const selection = {};
|
|
@@ -6882,7 +6931,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6882
6931
|
}
|
|
6883
6932
|
selection[key] = col2;
|
|
6884
6933
|
}
|
|
6885
|
-
return this.clone(
|
|
6934
|
+
return this.clone(
|
|
6935
|
+
this.projectionFacet.select(this.context, selection)
|
|
6936
|
+
);
|
|
6886
6937
|
}
|
|
6887
6938
|
/**
|
|
6888
6939
|
* Selects raw column expressions
|
|
@@ -6986,7 +7037,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6986
7037
|
*/
|
|
6987
7038
|
selectSubquery(alias, sub2) {
|
|
6988
7039
|
const query = resolveSelectQuery(sub2);
|
|
6989
|
-
return this.clone(
|
|
7040
|
+
return this.clone(
|
|
7041
|
+
this.projectionFacet.selectSubquery(this.context, alias, query)
|
|
7042
|
+
);
|
|
6990
7043
|
}
|
|
6991
7044
|
/**
|
|
6992
7045
|
* Adds a JOIN against a derived table (subquery with alias)
|
|
@@ -7219,7 +7272,8 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
7219
7272
|
ensureDefaultSelection() {
|
|
7220
7273
|
const columns = this.context.state.ast.columns;
|
|
7221
7274
|
if (!columns || columns.length === 0) {
|
|
7222
|
-
|
|
7275
|
+
const columnKeys = Object.keys(this.env.table.columns);
|
|
7276
|
+
return this.select(...columnKeys);
|
|
7223
7277
|
}
|
|
7224
7278
|
return this;
|
|
7225
7279
|
}
|
|
@@ -7255,7 +7309,8 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
7255
7309
|
*/
|
|
7256
7310
|
async executePlain(ctx) {
|
|
7257
7311
|
const builder = this.ensureDefaultSelection();
|
|
7258
|
-
|
|
7312
|
+
const rows = await executeHydratedPlain(ctx, builder);
|
|
7313
|
+
return rows;
|
|
7259
7314
|
}
|
|
7260
7315
|
/**
|
|
7261
7316
|
* Executes the query and returns results as real class instances.
|
|
@@ -9740,45 +9795,47 @@ var fn = (key, args) => ({
|
|
|
9740
9795
|
fn: key,
|
|
9741
9796
|
args: args.map(toOperand2)
|
|
9742
9797
|
});
|
|
9743
|
-
var
|
|
9744
|
-
var
|
|
9745
|
-
var
|
|
9798
|
+
var sfn = (key, args) => asType(fn(key, args));
|
|
9799
|
+
var nfn = (key, args) => asType(fn(key, args));
|
|
9800
|
+
var lower = (value) => sfn("LOWER", [value]);
|
|
9801
|
+
var upper = (value) => sfn("UPPER", [value]);
|
|
9802
|
+
var ascii = (value) => nfn("ASCII", [value]);
|
|
9746
9803
|
var char = (...codes) => {
|
|
9747
9804
|
if (codes.length === 0) throw new Error("char() expects at least 1 argument");
|
|
9748
|
-
return
|
|
9805
|
+
return sfn("CHAR", codes);
|
|
9749
9806
|
};
|
|
9750
|
-
var charLength = (value) =>
|
|
9751
|
-
var length = (value) =>
|
|
9752
|
-
var trim = (value, chars) => chars === void 0 ?
|
|
9753
|
-
var ltrim = (value) =>
|
|
9754
|
-
var rtrim = (value) =>
|
|
9807
|
+
var charLength = (value) => nfn("CHAR_LENGTH", [value]);
|
|
9808
|
+
var length = (value) => nfn("LENGTH", [value]);
|
|
9809
|
+
var trim = (value, chars) => chars === void 0 ? sfn("TRIM", [value]) : sfn("TRIM", [value, chars]);
|
|
9810
|
+
var ltrim = (value) => sfn("LTRIM", [value]);
|
|
9811
|
+
var rtrim = (value) => sfn("RTRIM", [value]);
|
|
9755
9812
|
var concat = (...args) => {
|
|
9756
9813
|
if (args.length < 2) throw new Error("concat() expects at least 2 arguments");
|
|
9757
|
-
return
|
|
9814
|
+
return sfn("CONCAT", args);
|
|
9758
9815
|
};
|
|
9759
9816
|
var concatWs = (separator, ...args) => {
|
|
9760
9817
|
if (args.length < 1) throw new Error("concatWs() expects at least 2 arguments including the separator");
|
|
9761
|
-
return
|
|
9762
|
-
};
|
|
9763
|
-
var substr = (value, start, length2) => length2 === void 0 ?
|
|
9764
|
-
var left = (value, len) =>
|
|
9765
|
-
var right = (value, len) =>
|
|
9766
|
-
var position = (substring, value) =>
|
|
9767
|
-
var instr = (value, substring) =>
|
|
9768
|
-
var locate = (substring, value, start) => start === void 0 ?
|
|
9769
|
-
var replace = (value, search, replacement) =>
|
|
9770
|
-
var repeat = (value, count2) =>
|
|
9771
|
-
var lpad = (value, len, pad) =>
|
|
9772
|
-
var rpad = (value, len, pad) =>
|
|
9773
|
-
var space = (count2) =>
|
|
9774
|
-
var reverse = (value) =>
|
|
9775
|
-
var initcap = (value) =>
|
|
9776
|
-
var md5 = (value) =>
|
|
9777
|
-
var sha1 = (value) =>
|
|
9778
|
-
var sha2 = (value, bits) =>
|
|
9779
|
-
var bitLength = (value) =>
|
|
9780
|
-
var octetLength = (value) =>
|
|
9781
|
-
var chr = (code) =>
|
|
9818
|
+
return sfn("CONCAT_WS", [separator, ...args]);
|
|
9819
|
+
};
|
|
9820
|
+
var substr = (value, start, length2) => length2 === void 0 ? sfn("SUBSTR", [value, start]) : sfn("SUBSTR", [value, start, length2]);
|
|
9821
|
+
var left = (value, len) => sfn("LEFT", [value, len]);
|
|
9822
|
+
var right = (value, len) => sfn("RIGHT", [value, len]);
|
|
9823
|
+
var position = (substring, value) => nfn("POSITION", [substring, value]);
|
|
9824
|
+
var instr = (value, substring) => nfn("INSTR", [value, substring]);
|
|
9825
|
+
var locate = (substring, value, start) => start === void 0 ? nfn("LOCATE", [substring, value]) : nfn("LOCATE", [substring, value, start]);
|
|
9826
|
+
var replace = (value, search, replacement) => sfn("REPLACE", [value, search, replacement]);
|
|
9827
|
+
var repeat = (value, count2) => sfn("REPEAT", [value, count2]);
|
|
9828
|
+
var lpad = (value, len, pad) => sfn("LPAD", [value, len, pad]);
|
|
9829
|
+
var rpad = (value, len, pad) => sfn("RPAD", [value, len, pad]);
|
|
9830
|
+
var space = (count2) => sfn("SPACE", [count2]);
|
|
9831
|
+
var reverse = (value) => sfn("REVERSE", [value]);
|
|
9832
|
+
var initcap = (value) => sfn("INITCAP", [value]);
|
|
9833
|
+
var md5 = (value) => sfn("MD5", [value]);
|
|
9834
|
+
var sha1 = (value) => sfn("SHA1", [value]);
|
|
9835
|
+
var sha2 = (value, bits) => sfn("SHA2", [value, bits]);
|
|
9836
|
+
var bitLength = (value) => nfn("BIT_LENGTH", [value]);
|
|
9837
|
+
var octetLength = (value) => nfn("OCTET_LENGTH", [value]);
|
|
9838
|
+
var chr = (code) => sfn("CHR", [code]);
|
|
9782
9839
|
|
|
9783
9840
|
// src/core/ddl/introspect/functions/mssql.ts
|
|
9784
9841
|
var isColumnReference = (value) => typeof value === "object" && value !== null && !("type" in value) && "name" in value && typeof value.name === "string";
|
|
@@ -10307,38 +10364,39 @@ var fn3 = (key, args) => ({
|
|
|
10307
10364
|
fn: key,
|
|
10308
10365
|
args: args.map(toOperand3)
|
|
10309
10366
|
});
|
|
10310
|
-
var
|
|
10311
|
-
var
|
|
10312
|
-
var
|
|
10313
|
-
var
|
|
10314
|
-
var
|
|
10315
|
-
var
|
|
10316
|
-
var
|
|
10317
|
-
var
|
|
10318
|
-
var
|
|
10319
|
-
var
|
|
10320
|
-
var
|
|
10321
|
-
var
|
|
10322
|
-
var
|
|
10323
|
-
var
|
|
10324
|
-
var
|
|
10325
|
-
var
|
|
10326
|
-
var
|
|
10327
|
-
var
|
|
10328
|
-
var
|
|
10329
|
-
var
|
|
10330
|
-
var
|
|
10331
|
-
var
|
|
10332
|
-
var
|
|
10333
|
-
var
|
|
10334
|
-
var
|
|
10335
|
-
var
|
|
10336
|
-
var
|
|
10337
|
-
var
|
|
10338
|
-
var
|
|
10339
|
-
var
|
|
10340
|
-
var
|
|
10341
|
-
var
|
|
10367
|
+
var nfn2 = (key, args) => asType(fn3(key, args));
|
|
10368
|
+
var abs = (value) => nfn2("ABS", [value]);
|
|
10369
|
+
var acos = (value) => nfn2("ACOS", [value]);
|
|
10370
|
+
var asin = (value) => nfn2("ASIN", [value]);
|
|
10371
|
+
var atan = (value) => nfn2("ATAN", [value]);
|
|
10372
|
+
var atan2 = (y, x) => nfn2("ATAN2", [y, x]);
|
|
10373
|
+
var ceil = (value) => nfn2("CEIL", [value]);
|
|
10374
|
+
var ceiling = (value) => nfn2("CEILING", [value]);
|
|
10375
|
+
var cos = (value) => nfn2("COS", [value]);
|
|
10376
|
+
var cot = (value) => nfn2("COT", [value]);
|
|
10377
|
+
var degrees = (value) => nfn2("DEGREES", [value]);
|
|
10378
|
+
var exp = (value) => nfn2("EXP", [value]);
|
|
10379
|
+
var floor = (value) => nfn2("FLOOR", [value]);
|
|
10380
|
+
var ln = (value) => nfn2("LN", [value]);
|
|
10381
|
+
var log = (value) => nfn2("LOG", [value]);
|
|
10382
|
+
var log10 = (value) => nfn2("LOG10", [value]);
|
|
10383
|
+
var logBase = (base, value) => nfn2("LOG_BASE", [base, value]);
|
|
10384
|
+
var mod = (x, y) => nfn2("MOD", [x, y]);
|
|
10385
|
+
var pi = () => nfn2("PI", []);
|
|
10386
|
+
var power = (x, y) => nfn2("POWER", [x, y]);
|
|
10387
|
+
var pow = (x, y) => nfn2("POW", [x, y]);
|
|
10388
|
+
var radians = (value) => nfn2("RADIANS", [value]);
|
|
10389
|
+
var random = () => nfn2("RANDOM", []);
|
|
10390
|
+
var rand = () => nfn2("RAND", []);
|
|
10391
|
+
var round = (value, decimals) => decimals === void 0 ? nfn2("ROUND", [value]) : nfn2("ROUND", [value, decimals]);
|
|
10392
|
+
var sign = (value) => nfn2("SIGN", [value]);
|
|
10393
|
+
var sin = (value) => nfn2("SIN", [value]);
|
|
10394
|
+
var sqrt = (value) => nfn2("SQRT", [value]);
|
|
10395
|
+
var tan = (value) => nfn2("TAN", [value]);
|
|
10396
|
+
var trunc = (value, decimals) => decimals === void 0 ? nfn2("TRUNC", [value]) : nfn2("TRUNC", [value, decimals]);
|
|
10397
|
+
var truncate = (value, decimals) => nfn2("TRUNCATE", [value, decimals]);
|
|
10398
|
+
var log2 = (value) => nfn2("LOG2", [value]);
|
|
10399
|
+
var cbrt = (value) => nfn2("CBRT", [value]);
|
|
10342
10400
|
|
|
10343
10401
|
// src/core/functions/datetime.ts
|
|
10344
10402
|
var isColumnDef3 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
|
|
@@ -10353,31 +10411,34 @@ var fn4 = (key, args) => ({
|
|
|
10353
10411
|
fn: key,
|
|
10354
10412
|
args: args.map(toOperand4)
|
|
10355
10413
|
});
|
|
10356
|
-
var
|
|
10357
|
-
var
|
|
10358
|
-
var
|
|
10359
|
-
var
|
|
10360
|
-
var
|
|
10361
|
-
var
|
|
10362
|
-
var
|
|
10363
|
-
var
|
|
10364
|
-
var
|
|
10365
|
-
var
|
|
10366
|
-
var
|
|
10367
|
-
var
|
|
10368
|
-
var
|
|
10369
|
-
var
|
|
10370
|
-
var
|
|
10371
|
-
var
|
|
10372
|
-
var
|
|
10373
|
-
var
|
|
10374
|
-
var
|
|
10375
|
-
var
|
|
10376
|
-
var
|
|
10377
|
-
var
|
|
10378
|
-
var
|
|
10379
|
-
var
|
|
10380
|
-
var
|
|
10414
|
+
var dfn = (key, args) => asType(fn4(key, args));
|
|
10415
|
+
var nfn3 = (key, args) => asType(fn4(key, args));
|
|
10416
|
+
var sfn2 = (key, args) => asType(fn4(key, args));
|
|
10417
|
+
var now = () => dfn("NOW", []);
|
|
10418
|
+
var currentDate = () => dfn("CURRENT_DATE", []);
|
|
10419
|
+
var currentTime = () => dfn("CURRENT_TIME", []);
|
|
10420
|
+
var utcNow = () => dfn("UTC_NOW", []);
|
|
10421
|
+
var localTime = () => dfn("LOCALTIME", []);
|
|
10422
|
+
var localTimestamp = () => dfn("LOCALTIMESTAMP", []);
|
|
10423
|
+
var extract = (part, date) => nfn3("EXTRACT", [part, date]);
|
|
10424
|
+
var year = (date) => nfn3("YEAR", [date]);
|
|
10425
|
+
var month = (date) => nfn3("MONTH", [date]);
|
|
10426
|
+
var day = (date) => nfn3("DAY", [date]);
|
|
10427
|
+
var dateAdd = (date, interval, unit) => dfn("DATE_ADD", [date, interval, unit]);
|
|
10428
|
+
var dateSub = (date, interval, unit) => dfn("DATE_SUB", [date, interval, unit]);
|
|
10429
|
+
var dateDiff = (date1, date2) => nfn3("DATE_DIFF", [date1, date2]);
|
|
10430
|
+
var dateFormat = (date, format) => sfn2("DATE_FORMAT", [date, format]);
|
|
10431
|
+
var unixTimestamp = () => nfn3("UNIX_TIMESTAMP", []);
|
|
10432
|
+
var fromUnixTime = (timestamp) => dfn("FROM_UNIXTIME", [timestamp]);
|
|
10433
|
+
var endOfMonth = (date) => dfn("END_OF_MONTH", [date]);
|
|
10434
|
+
var dayOfWeek = (date) => nfn3("DAY_OF_WEEK", [date]);
|
|
10435
|
+
var weekOfYear = (date) => nfn3("WEEK_OF_YEAR", [date]);
|
|
10436
|
+
var dateTrunc = (part, date) => dfn("DATE_TRUNC", [part, date]);
|
|
10437
|
+
var age = (timestamp, baseTimestamp) => baseTimestamp === void 0 ? sfn2("AGE", [timestamp]) : sfn2("AGE", [timestamp, baseTimestamp]);
|
|
10438
|
+
var hour = (date) => nfn3("HOUR", [date]);
|
|
10439
|
+
var minute = (date) => nfn3("MINUTE", [date]);
|
|
10440
|
+
var second = (date) => nfn3("SECOND", [date]);
|
|
10441
|
+
var quarter = (date) => nfn3("QUARTER", [date]);
|
|
10381
10442
|
|
|
10382
10443
|
// src/core/functions/control-flow.ts
|
|
10383
10444
|
var isColumnDef4 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
|
|
@@ -10392,18 +10453,19 @@ var fn5 = (key, args) => ({
|
|
|
10392
10453
|
fn: key,
|
|
10393
10454
|
args: args.map(toOperand5)
|
|
10394
10455
|
});
|
|
10456
|
+
var afn = (key, args) => asType(fn5(key, args));
|
|
10395
10457
|
var coalesce = (...args) => {
|
|
10396
10458
|
if (args.length < 2) throw new Error("coalesce() expects at least 2 arguments");
|
|
10397
|
-
return
|
|
10459
|
+
return afn("COALESCE", args);
|
|
10398
10460
|
};
|
|
10399
|
-
var nullif = (val1, val2) =>
|
|
10461
|
+
var nullif = (val1, val2) => afn("NULLIF", [val1, val2]);
|
|
10400
10462
|
var greatest = (...args) => {
|
|
10401
10463
|
if (args.length < 2) throw new Error("greatest() expects at least 2 arguments");
|
|
10402
|
-
return
|
|
10464
|
+
return afn("GREATEST", args);
|
|
10403
10465
|
};
|
|
10404
10466
|
var least = (...args) => {
|
|
10405
10467
|
if (args.length < 2) throw new Error("least() expects at least 2 arguments");
|
|
10406
|
-
return
|
|
10468
|
+
return afn("LEAST", args);
|
|
10407
10469
|
};
|
|
10408
10470
|
var ifNull = (val, defaultValue) => coalesce(val, defaultValue);
|
|
10409
10471
|
|
|
@@ -10420,10 +10482,12 @@ var fn6 = (key, args) => ({
|
|
|
10420
10482
|
fn: key,
|
|
10421
10483
|
args: args.map(toOperand6)
|
|
10422
10484
|
});
|
|
10423
|
-
var
|
|
10424
|
-
var
|
|
10425
|
-
var
|
|
10426
|
-
var
|
|
10485
|
+
var nfn4 = (key, args) => asType(fn6(key, args));
|
|
10486
|
+
var afn2 = (key, args) => asType(fn6(key, args));
|
|
10487
|
+
var jsonLength = (target, path) => path === void 0 ? nfn4("JSON_LENGTH", [target]) : nfn4("JSON_LENGTH", [target, path]);
|
|
10488
|
+
var jsonSet = (target, path, value) => afn2("JSON_SET", [target, path, value]);
|
|
10489
|
+
var jsonArrayAgg = (value) => afn2("JSON_ARRAYAGG", [value]);
|
|
10490
|
+
var jsonContains = (target, candidate, path) => path === void 0 ? afn2("JSON_CONTAINS", [target, candidate]) : afn2("JSON_CONTAINS", [target, candidate, path]);
|
|
10427
10491
|
|
|
10428
10492
|
// src/core/functions/array.ts
|
|
10429
10493
|
var isColumnDef6 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
|
|
@@ -10438,7 +10502,8 @@ var fn7 = (key, args) => ({
|
|
|
10438
10502
|
fn: key,
|
|
10439
10503
|
args: args.map(toOperand7)
|
|
10440
10504
|
});
|
|
10441
|
-
var
|
|
10505
|
+
var afn3 = (key, args) => asType(fn7(key, args));
|
|
10506
|
+
var arrayAppend = (array, value) => afn3("ARRAY_APPEND", [array, value]);
|
|
10442
10507
|
|
|
10443
10508
|
// src/orm/als.ts
|
|
10444
10509
|
var AsyncLocalStorage = class {
|
|
@@ -13011,6 +13076,7 @@ function createPooledExecutorFactory(opts) {
|
|
|
13011
13076
|
aliasRef,
|
|
13012
13077
|
and,
|
|
13013
13078
|
arrayAppend,
|
|
13079
|
+
asType,
|
|
13014
13080
|
ascii,
|
|
13015
13081
|
asin,
|
|
13016
13082
|
atan,
|
|
@@ -13076,6 +13142,8 @@ function createPooledExecutorFactory(opts) {
|
|
|
13076
13142
|
eq,
|
|
13077
13143
|
esel,
|
|
13078
13144
|
executeHydrated,
|
|
13145
|
+
executeHydratedPlain,
|
|
13146
|
+
executeHydratedPlainWithContexts,
|
|
13079
13147
|
executeHydratedWithContexts,
|
|
13080
13148
|
executeSchemaSql,
|
|
13081
13149
|
executeSchemaSqlFor,
|