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/dist/index.js
CHANGED
|
@@ -446,12 +446,24 @@ var createBinaryExpression = (operator, left2, right2, escape) => {
|
|
|
446
446
|
}
|
|
447
447
|
return node;
|
|
448
448
|
};
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
449
|
+
function eq(left2, right2) {
|
|
450
|
+
return createBinaryExpression("=", left2, right2);
|
|
451
|
+
}
|
|
452
|
+
function neq(left2, right2) {
|
|
453
|
+
return createBinaryExpression("!=", left2, right2);
|
|
454
|
+
}
|
|
455
|
+
function gt(left2, right2) {
|
|
456
|
+
return createBinaryExpression(">", left2, right2);
|
|
457
|
+
}
|
|
458
|
+
function gte(left2, right2) {
|
|
459
|
+
return createBinaryExpression(">=", left2, right2);
|
|
460
|
+
}
|
|
461
|
+
function lt(left2, right2) {
|
|
462
|
+
return createBinaryExpression("<", left2, right2);
|
|
463
|
+
}
|
|
464
|
+
function lte(left2, right2) {
|
|
465
|
+
return createBinaryExpression("<=", left2, right2);
|
|
466
|
+
}
|
|
455
467
|
var like = (left2, pattern, escape) => createBinaryExpression("LIKE", left2, pattern, escape);
|
|
456
468
|
var notLike = (left2, pattern, escape) => createBinaryExpression("NOT LIKE", left2, pattern, escape);
|
|
457
469
|
var and = (...operands) => ({
|
|
@@ -561,7 +573,7 @@ var buildWindowFunction = (name, args = [], partitionBy, orderBy) => {
|
|
|
561
573
|
if (orderBy && orderBy.length) {
|
|
562
574
|
node.orderBy = orderBy;
|
|
563
575
|
}
|
|
564
|
-
return node;
|
|
576
|
+
return asType(node);
|
|
565
577
|
};
|
|
566
578
|
var rowNumber = () => buildWindowFunction("ROW_NUMBER");
|
|
567
579
|
var rank = () => buildWindowFunction("RANK");
|
|
@@ -665,7 +677,7 @@ var ORDER_DIRECTIONS = {
|
|
|
665
677
|
};
|
|
666
678
|
|
|
667
679
|
// src/core/ast/aggregate-functions.ts
|
|
668
|
-
var buildAggregate = (name) => (col2) => ({
|
|
680
|
+
var buildAggregate = (name) => (col2) => asType({
|
|
669
681
|
type: "Function",
|
|
670
682
|
name,
|
|
671
683
|
args: [columnOperand(col2)]
|
|
@@ -675,7 +687,7 @@ var sum = buildAggregate("SUM");
|
|
|
675
687
|
var avg = buildAggregate("AVG");
|
|
676
688
|
var min = buildAggregate("MIN");
|
|
677
689
|
var max = buildAggregate("MAX");
|
|
678
|
-
var countAll = () => ({
|
|
690
|
+
var countAll = () => asType({
|
|
679
691
|
type: "Function",
|
|
680
692
|
name: "COUNT",
|
|
681
693
|
args: []
|
|
@@ -685,7 +697,7 @@ var toOrderByNode = (order) => ({
|
|
|
685
697
|
term: columnOperand(order.column),
|
|
686
698
|
direction: order.direction ?? ORDER_DIRECTIONS.ASC
|
|
687
699
|
});
|
|
688
|
-
var groupConcat = (col2, options) => ({
|
|
700
|
+
var groupConcat = (col2, options) => asType({
|
|
689
701
|
type: "Function",
|
|
690
702
|
name: "GROUP_CONCAT",
|
|
691
703
|
args: [columnOperand(col2)],
|
|
@@ -831,6 +843,9 @@ var toTableRef = (table) => ({
|
|
|
831
843
|
alias: hasAlias(table) ? table.alias : void 0
|
|
832
844
|
});
|
|
833
845
|
|
|
846
|
+
// src/core/ast/expression.ts
|
|
847
|
+
var asType = (expr) => expr;
|
|
848
|
+
|
|
834
849
|
// src/core/functions/function-registry.ts
|
|
835
850
|
var FunctionRegistry = class {
|
|
836
851
|
renderers = /* @__PURE__ */ new Map();
|
|
@@ -3444,10 +3459,9 @@ var HydrationPlanner = class _HydrationPlanner {
|
|
|
3444
3459
|
const rootCols = new Set(currentPlan.rootColumns);
|
|
3445
3460
|
let changed = false;
|
|
3446
3461
|
columns.forEach((node) => {
|
|
3447
|
-
|
|
3448
|
-
if (
|
|
3449
|
-
|
|
3450
|
-
if (isRelationAlias(alias)) return;
|
|
3462
|
+
const alias = node.type === "Column" ? node.alias || node.name : node.alias;
|
|
3463
|
+
if (!alias || isRelationAlias(alias)) return;
|
|
3464
|
+
if (node.type === "Column" && node.table !== this.table.name) return;
|
|
3451
3465
|
if (!rootCols.has(alias)) {
|
|
3452
3466
|
rootCols.add(alias);
|
|
3453
3467
|
changed = true;
|
|
@@ -5913,9 +5927,22 @@ var executeWithContexts = async (execCtx, entityCtx, qb) => {
|
|
|
5913
5927
|
await loadLazyRelationsForTable(entityCtx, qb.getTable(), lazyRelations, lazyRelationOptions);
|
|
5914
5928
|
return entities;
|
|
5915
5929
|
};
|
|
5930
|
+
var executePlainWithContexts = async (execCtx, qb) => {
|
|
5931
|
+
const ast = qb.getAST();
|
|
5932
|
+
const compiled = execCtx.dialect.compileSelect(ast);
|
|
5933
|
+
const executed = await execCtx.interceptors.run({ sql: compiled.sql, params: compiled.params }, execCtx.executor);
|
|
5934
|
+
const rows = flattenResults(executed);
|
|
5935
|
+
if (ast.setOps && ast.setOps.length > 0) {
|
|
5936
|
+
return rows;
|
|
5937
|
+
}
|
|
5938
|
+
return hydrateRows(rows, qb.getHydrationPlan());
|
|
5939
|
+
};
|
|
5916
5940
|
async function executeHydrated(session, qb) {
|
|
5917
5941
|
return executeWithContexts(session.getExecutionContext(), session, qb);
|
|
5918
5942
|
}
|
|
5943
|
+
async function executeHydratedPlain(session, qb) {
|
|
5944
|
+
return executePlainWithContexts(session.getExecutionContext(), qb);
|
|
5945
|
+
}
|
|
5919
5946
|
async function executeHydratedWithContexts(execCtx, hydCtx, qb) {
|
|
5920
5947
|
const entityCtx = hydCtx.entityContext;
|
|
5921
5948
|
if (!entityCtx) {
|
|
@@ -5923,6 +5950,9 @@ async function executeHydratedWithContexts(execCtx, hydCtx, qb) {
|
|
|
5923
5950
|
}
|
|
5924
5951
|
return executeWithContexts(execCtx, entityCtx, qb);
|
|
5925
5952
|
}
|
|
5953
|
+
async function executeHydratedPlainWithContexts(execCtx, qb) {
|
|
5954
|
+
return executePlainWithContexts(execCtx, qb);
|
|
5955
|
+
}
|
|
5926
5956
|
var loadLazyRelationsForTable = async (ctx, table, lazyRelations, lazyRelationOptions) => {
|
|
5927
5957
|
if (!lazyRelations.length) return;
|
|
5928
5958
|
const tracked = ctx.getEntitiesForTable(table);
|
|
@@ -6056,8 +6086,11 @@ var DefaultEntityMaterializer = class {
|
|
|
6056
6086
|
this.strategy = strategy;
|
|
6057
6087
|
}
|
|
6058
6088
|
materialize(ctor, row) {
|
|
6089
|
+
if (hasEntityMeta(row)) {
|
|
6090
|
+
return this.materializeEntityProxy(ctor, row);
|
|
6091
|
+
}
|
|
6059
6092
|
const instance = this.strategy.materialize(ctor, row);
|
|
6060
|
-
this.materializeRelations(instance
|
|
6093
|
+
this.materializeRelations(instance);
|
|
6061
6094
|
return instance;
|
|
6062
6095
|
}
|
|
6063
6096
|
materializeMany(ctor, rows) {
|
|
@@ -6066,9 +6099,9 @@ var DefaultEntityMaterializer = class {
|
|
|
6066
6099
|
/**
|
|
6067
6100
|
* Recursively materializes nested relation data.
|
|
6068
6101
|
*/
|
|
6069
|
-
materializeRelations(instance
|
|
6102
|
+
materializeRelations(instance) {
|
|
6070
6103
|
rebuildRegistry();
|
|
6071
|
-
for (const
|
|
6104
|
+
for (const value of Object.values(instance)) {
|
|
6072
6105
|
if (value === null || value === void 0) continue;
|
|
6073
6106
|
if (typeof value === "object" && !Array.isArray(value)) {
|
|
6074
6107
|
const nested = value;
|
|
@@ -6090,6 +6123,17 @@ var DefaultEntityMaterializer = class {
|
|
|
6090
6123
|
(k) => k.endsWith("Id") || k === "createdAt" || k === "updatedAt"
|
|
6091
6124
|
);
|
|
6092
6125
|
}
|
|
6126
|
+
materializeEntityProxy(ctor, row) {
|
|
6127
|
+
const proxy = row;
|
|
6128
|
+
const baseline = this.strategy.materialize(ctor, {});
|
|
6129
|
+
for (const key of Object.keys(baseline)) {
|
|
6130
|
+
if (!Object.prototype.hasOwnProperty.call(proxy, key)) {
|
|
6131
|
+
proxy[key] = baseline[key];
|
|
6132
|
+
}
|
|
6133
|
+
}
|
|
6134
|
+
Object.setPrototypeOf(proxy, ctor.prototype);
|
|
6135
|
+
return proxy;
|
|
6136
|
+
}
|
|
6093
6137
|
};
|
|
6094
6138
|
var materializeAs = (ctor, results) => {
|
|
6095
6139
|
const materializer = new DefaultEntityMaterializer();
|
|
@@ -6599,7 +6643,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6599
6643
|
select(...args) {
|
|
6600
6644
|
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && typeof args[0] !== "string") {
|
|
6601
6645
|
const columns = args[0];
|
|
6602
|
-
return this.clone(
|
|
6646
|
+
return this.clone(
|
|
6647
|
+
this.projectionFacet.select(this.context, columns)
|
|
6648
|
+
);
|
|
6603
6649
|
}
|
|
6604
6650
|
const cols = args;
|
|
6605
6651
|
const selection = {};
|
|
@@ -6610,7 +6656,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6610
6656
|
}
|
|
6611
6657
|
selection[key] = col2;
|
|
6612
6658
|
}
|
|
6613
|
-
return this.clone(
|
|
6659
|
+
return this.clone(
|
|
6660
|
+
this.projectionFacet.select(this.context, selection)
|
|
6661
|
+
);
|
|
6614
6662
|
}
|
|
6615
6663
|
/**
|
|
6616
6664
|
* Selects raw column expressions
|
|
@@ -6714,7 +6762,9 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6714
6762
|
*/
|
|
6715
6763
|
selectSubquery(alias, sub2) {
|
|
6716
6764
|
const query = resolveSelectQuery(sub2);
|
|
6717
|
-
return this.clone(
|
|
6765
|
+
return this.clone(
|
|
6766
|
+
this.projectionFacet.selectSubquery(this.context, alias, query)
|
|
6767
|
+
);
|
|
6718
6768
|
}
|
|
6719
6769
|
/**
|
|
6720
6770
|
* Adds a JOIN against a derived table (subquery with alias)
|
|
@@ -6947,7 +6997,8 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6947
6997
|
ensureDefaultSelection() {
|
|
6948
6998
|
const columns = this.context.state.ast.columns;
|
|
6949
6999
|
if (!columns || columns.length === 0) {
|
|
6950
|
-
|
|
7000
|
+
const columnKeys = Object.keys(this.env.table.columns);
|
|
7001
|
+
return this.select(...columnKeys);
|
|
6951
7002
|
}
|
|
6952
7003
|
return this;
|
|
6953
7004
|
}
|
|
@@ -6983,7 +7034,8 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
|
|
|
6983
7034
|
*/
|
|
6984
7035
|
async executePlain(ctx) {
|
|
6985
7036
|
const builder = this.ensureDefaultSelection();
|
|
6986
|
-
|
|
7037
|
+
const rows = await executeHydratedPlain(ctx, builder);
|
|
7038
|
+
return rows;
|
|
6987
7039
|
}
|
|
6988
7040
|
/**
|
|
6989
7041
|
* Executes the query and returns results as real class instances.
|
|
@@ -9468,45 +9520,47 @@ var fn = (key, args) => ({
|
|
|
9468
9520
|
fn: key,
|
|
9469
9521
|
args: args.map(toOperand2)
|
|
9470
9522
|
});
|
|
9471
|
-
var
|
|
9472
|
-
var
|
|
9473
|
-
var
|
|
9523
|
+
var sfn = (key, args) => asType(fn(key, args));
|
|
9524
|
+
var nfn = (key, args) => asType(fn(key, args));
|
|
9525
|
+
var lower = (value) => sfn("LOWER", [value]);
|
|
9526
|
+
var upper = (value) => sfn("UPPER", [value]);
|
|
9527
|
+
var ascii = (value) => nfn("ASCII", [value]);
|
|
9474
9528
|
var char = (...codes) => {
|
|
9475
9529
|
if (codes.length === 0) throw new Error("char() expects at least 1 argument");
|
|
9476
|
-
return
|
|
9530
|
+
return sfn("CHAR", codes);
|
|
9477
9531
|
};
|
|
9478
|
-
var charLength = (value) =>
|
|
9479
|
-
var length = (value) =>
|
|
9480
|
-
var trim = (value, chars) => chars === void 0 ?
|
|
9481
|
-
var ltrim = (value) =>
|
|
9482
|
-
var rtrim = (value) =>
|
|
9532
|
+
var charLength = (value) => nfn("CHAR_LENGTH", [value]);
|
|
9533
|
+
var length = (value) => nfn("LENGTH", [value]);
|
|
9534
|
+
var trim = (value, chars) => chars === void 0 ? sfn("TRIM", [value]) : sfn("TRIM", [value, chars]);
|
|
9535
|
+
var ltrim = (value) => sfn("LTRIM", [value]);
|
|
9536
|
+
var rtrim = (value) => sfn("RTRIM", [value]);
|
|
9483
9537
|
var concat = (...args) => {
|
|
9484
9538
|
if (args.length < 2) throw new Error("concat() expects at least 2 arguments");
|
|
9485
|
-
return
|
|
9539
|
+
return sfn("CONCAT", args);
|
|
9486
9540
|
};
|
|
9487
9541
|
var concatWs = (separator, ...args) => {
|
|
9488
9542
|
if (args.length < 1) throw new Error("concatWs() expects at least 2 arguments including the separator");
|
|
9489
|
-
return
|
|
9490
|
-
};
|
|
9491
|
-
var substr = (value, start, length2) => length2 === void 0 ?
|
|
9492
|
-
var left = (value, len) =>
|
|
9493
|
-
var right = (value, len) =>
|
|
9494
|
-
var position = (substring, value) =>
|
|
9495
|
-
var instr = (value, substring) =>
|
|
9496
|
-
var locate = (substring, value, start) => start === void 0 ?
|
|
9497
|
-
var replace = (value, search, replacement) =>
|
|
9498
|
-
var repeat = (value, count2) =>
|
|
9499
|
-
var lpad = (value, len, pad) =>
|
|
9500
|
-
var rpad = (value, len, pad) =>
|
|
9501
|
-
var space = (count2) =>
|
|
9502
|
-
var reverse = (value) =>
|
|
9503
|
-
var initcap = (value) =>
|
|
9504
|
-
var md5 = (value) =>
|
|
9505
|
-
var sha1 = (value) =>
|
|
9506
|
-
var sha2 = (value, bits) =>
|
|
9507
|
-
var bitLength = (value) =>
|
|
9508
|
-
var octetLength = (value) =>
|
|
9509
|
-
var chr = (code) =>
|
|
9543
|
+
return sfn("CONCAT_WS", [separator, ...args]);
|
|
9544
|
+
};
|
|
9545
|
+
var substr = (value, start, length2) => length2 === void 0 ? sfn("SUBSTR", [value, start]) : sfn("SUBSTR", [value, start, length2]);
|
|
9546
|
+
var left = (value, len) => sfn("LEFT", [value, len]);
|
|
9547
|
+
var right = (value, len) => sfn("RIGHT", [value, len]);
|
|
9548
|
+
var position = (substring, value) => nfn("POSITION", [substring, value]);
|
|
9549
|
+
var instr = (value, substring) => nfn("INSTR", [value, substring]);
|
|
9550
|
+
var locate = (substring, value, start) => start === void 0 ? nfn("LOCATE", [substring, value]) : nfn("LOCATE", [substring, value, start]);
|
|
9551
|
+
var replace = (value, search, replacement) => sfn("REPLACE", [value, search, replacement]);
|
|
9552
|
+
var repeat = (value, count2) => sfn("REPEAT", [value, count2]);
|
|
9553
|
+
var lpad = (value, len, pad) => sfn("LPAD", [value, len, pad]);
|
|
9554
|
+
var rpad = (value, len, pad) => sfn("RPAD", [value, len, pad]);
|
|
9555
|
+
var space = (count2) => sfn("SPACE", [count2]);
|
|
9556
|
+
var reverse = (value) => sfn("REVERSE", [value]);
|
|
9557
|
+
var initcap = (value) => sfn("INITCAP", [value]);
|
|
9558
|
+
var md5 = (value) => sfn("MD5", [value]);
|
|
9559
|
+
var sha1 = (value) => sfn("SHA1", [value]);
|
|
9560
|
+
var sha2 = (value, bits) => sfn("SHA2", [value, bits]);
|
|
9561
|
+
var bitLength = (value) => nfn("BIT_LENGTH", [value]);
|
|
9562
|
+
var octetLength = (value) => nfn("OCTET_LENGTH", [value]);
|
|
9563
|
+
var chr = (code) => sfn("CHR", [code]);
|
|
9510
9564
|
|
|
9511
9565
|
// src/core/ddl/introspect/functions/mssql.ts
|
|
9512
9566
|
var isColumnReference = (value) => typeof value === "object" && value !== null && !("type" in value) && "name" in value && typeof value.name === "string";
|
|
@@ -10035,38 +10089,39 @@ var fn3 = (key, args) => ({
|
|
|
10035
10089
|
fn: key,
|
|
10036
10090
|
args: args.map(toOperand3)
|
|
10037
10091
|
});
|
|
10038
|
-
var
|
|
10039
|
-
var
|
|
10040
|
-
var
|
|
10041
|
-
var
|
|
10042
|
-
var
|
|
10043
|
-
var
|
|
10044
|
-
var
|
|
10045
|
-
var
|
|
10046
|
-
var
|
|
10047
|
-
var
|
|
10048
|
-
var
|
|
10049
|
-
var
|
|
10050
|
-
var
|
|
10051
|
-
var
|
|
10052
|
-
var
|
|
10053
|
-
var
|
|
10054
|
-
var
|
|
10055
|
-
var
|
|
10056
|
-
var
|
|
10057
|
-
var
|
|
10058
|
-
var
|
|
10059
|
-
var
|
|
10060
|
-
var
|
|
10061
|
-
var
|
|
10062
|
-
var
|
|
10063
|
-
var
|
|
10064
|
-
var
|
|
10065
|
-
var
|
|
10066
|
-
var
|
|
10067
|
-
var
|
|
10068
|
-
var
|
|
10069
|
-
var
|
|
10092
|
+
var nfn2 = (key, args) => asType(fn3(key, args));
|
|
10093
|
+
var abs = (value) => nfn2("ABS", [value]);
|
|
10094
|
+
var acos = (value) => nfn2("ACOS", [value]);
|
|
10095
|
+
var asin = (value) => nfn2("ASIN", [value]);
|
|
10096
|
+
var atan = (value) => nfn2("ATAN", [value]);
|
|
10097
|
+
var atan2 = (y, x) => nfn2("ATAN2", [y, x]);
|
|
10098
|
+
var ceil = (value) => nfn2("CEIL", [value]);
|
|
10099
|
+
var ceiling = (value) => nfn2("CEILING", [value]);
|
|
10100
|
+
var cos = (value) => nfn2("COS", [value]);
|
|
10101
|
+
var cot = (value) => nfn2("COT", [value]);
|
|
10102
|
+
var degrees = (value) => nfn2("DEGREES", [value]);
|
|
10103
|
+
var exp = (value) => nfn2("EXP", [value]);
|
|
10104
|
+
var floor = (value) => nfn2("FLOOR", [value]);
|
|
10105
|
+
var ln = (value) => nfn2("LN", [value]);
|
|
10106
|
+
var log = (value) => nfn2("LOG", [value]);
|
|
10107
|
+
var log10 = (value) => nfn2("LOG10", [value]);
|
|
10108
|
+
var logBase = (base, value) => nfn2("LOG_BASE", [base, value]);
|
|
10109
|
+
var mod = (x, y) => nfn2("MOD", [x, y]);
|
|
10110
|
+
var pi = () => nfn2("PI", []);
|
|
10111
|
+
var power = (x, y) => nfn2("POWER", [x, y]);
|
|
10112
|
+
var pow = (x, y) => nfn2("POW", [x, y]);
|
|
10113
|
+
var radians = (value) => nfn2("RADIANS", [value]);
|
|
10114
|
+
var random = () => nfn2("RANDOM", []);
|
|
10115
|
+
var rand = () => nfn2("RAND", []);
|
|
10116
|
+
var round = (value, decimals) => decimals === void 0 ? nfn2("ROUND", [value]) : nfn2("ROUND", [value, decimals]);
|
|
10117
|
+
var sign = (value) => nfn2("SIGN", [value]);
|
|
10118
|
+
var sin = (value) => nfn2("SIN", [value]);
|
|
10119
|
+
var sqrt = (value) => nfn2("SQRT", [value]);
|
|
10120
|
+
var tan = (value) => nfn2("TAN", [value]);
|
|
10121
|
+
var trunc = (value, decimals) => decimals === void 0 ? nfn2("TRUNC", [value]) : nfn2("TRUNC", [value, decimals]);
|
|
10122
|
+
var truncate = (value, decimals) => nfn2("TRUNCATE", [value, decimals]);
|
|
10123
|
+
var log2 = (value) => nfn2("LOG2", [value]);
|
|
10124
|
+
var cbrt = (value) => nfn2("CBRT", [value]);
|
|
10070
10125
|
|
|
10071
10126
|
// src/core/functions/datetime.ts
|
|
10072
10127
|
var isColumnDef3 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
|
|
@@ -10081,31 +10136,34 @@ var fn4 = (key, args) => ({
|
|
|
10081
10136
|
fn: key,
|
|
10082
10137
|
args: args.map(toOperand4)
|
|
10083
10138
|
});
|
|
10084
|
-
var
|
|
10085
|
-
var
|
|
10086
|
-
var
|
|
10087
|
-
var
|
|
10088
|
-
var
|
|
10089
|
-
var
|
|
10090
|
-
var
|
|
10091
|
-
var
|
|
10092
|
-
var
|
|
10093
|
-
var
|
|
10094
|
-
var
|
|
10095
|
-
var
|
|
10096
|
-
var
|
|
10097
|
-
var
|
|
10098
|
-
var
|
|
10099
|
-
var
|
|
10100
|
-
var
|
|
10101
|
-
var
|
|
10102
|
-
var
|
|
10103
|
-
var
|
|
10104
|
-
var
|
|
10105
|
-
var
|
|
10106
|
-
var
|
|
10107
|
-
var
|
|
10108
|
-
var
|
|
10139
|
+
var dfn = (key, args) => asType(fn4(key, args));
|
|
10140
|
+
var nfn3 = (key, args) => asType(fn4(key, args));
|
|
10141
|
+
var sfn2 = (key, args) => asType(fn4(key, args));
|
|
10142
|
+
var now = () => dfn("NOW", []);
|
|
10143
|
+
var currentDate = () => dfn("CURRENT_DATE", []);
|
|
10144
|
+
var currentTime = () => dfn("CURRENT_TIME", []);
|
|
10145
|
+
var utcNow = () => dfn("UTC_NOW", []);
|
|
10146
|
+
var localTime = () => dfn("LOCALTIME", []);
|
|
10147
|
+
var localTimestamp = () => dfn("LOCALTIMESTAMP", []);
|
|
10148
|
+
var extract = (part, date) => nfn3("EXTRACT", [part, date]);
|
|
10149
|
+
var year = (date) => nfn3("YEAR", [date]);
|
|
10150
|
+
var month = (date) => nfn3("MONTH", [date]);
|
|
10151
|
+
var day = (date) => nfn3("DAY", [date]);
|
|
10152
|
+
var dateAdd = (date, interval, unit) => dfn("DATE_ADD", [date, interval, unit]);
|
|
10153
|
+
var dateSub = (date, interval, unit) => dfn("DATE_SUB", [date, interval, unit]);
|
|
10154
|
+
var dateDiff = (date1, date2) => nfn3("DATE_DIFF", [date1, date2]);
|
|
10155
|
+
var dateFormat = (date, format) => sfn2("DATE_FORMAT", [date, format]);
|
|
10156
|
+
var unixTimestamp = () => nfn3("UNIX_TIMESTAMP", []);
|
|
10157
|
+
var fromUnixTime = (timestamp) => dfn("FROM_UNIXTIME", [timestamp]);
|
|
10158
|
+
var endOfMonth = (date) => dfn("END_OF_MONTH", [date]);
|
|
10159
|
+
var dayOfWeek = (date) => nfn3("DAY_OF_WEEK", [date]);
|
|
10160
|
+
var weekOfYear = (date) => nfn3("WEEK_OF_YEAR", [date]);
|
|
10161
|
+
var dateTrunc = (part, date) => dfn("DATE_TRUNC", [part, date]);
|
|
10162
|
+
var age = (timestamp, baseTimestamp) => baseTimestamp === void 0 ? sfn2("AGE", [timestamp]) : sfn2("AGE", [timestamp, baseTimestamp]);
|
|
10163
|
+
var hour = (date) => nfn3("HOUR", [date]);
|
|
10164
|
+
var minute = (date) => nfn3("MINUTE", [date]);
|
|
10165
|
+
var second = (date) => nfn3("SECOND", [date]);
|
|
10166
|
+
var quarter = (date) => nfn3("QUARTER", [date]);
|
|
10109
10167
|
|
|
10110
10168
|
// src/core/functions/control-flow.ts
|
|
10111
10169
|
var isColumnDef4 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
|
|
@@ -10120,18 +10178,19 @@ var fn5 = (key, args) => ({
|
|
|
10120
10178
|
fn: key,
|
|
10121
10179
|
args: args.map(toOperand5)
|
|
10122
10180
|
});
|
|
10181
|
+
var afn = (key, args) => asType(fn5(key, args));
|
|
10123
10182
|
var coalesce = (...args) => {
|
|
10124
10183
|
if (args.length < 2) throw new Error("coalesce() expects at least 2 arguments");
|
|
10125
|
-
return
|
|
10184
|
+
return afn("COALESCE", args);
|
|
10126
10185
|
};
|
|
10127
|
-
var nullif = (val1, val2) =>
|
|
10186
|
+
var nullif = (val1, val2) => afn("NULLIF", [val1, val2]);
|
|
10128
10187
|
var greatest = (...args) => {
|
|
10129
10188
|
if (args.length < 2) throw new Error("greatest() expects at least 2 arguments");
|
|
10130
|
-
return
|
|
10189
|
+
return afn("GREATEST", args);
|
|
10131
10190
|
};
|
|
10132
10191
|
var least = (...args) => {
|
|
10133
10192
|
if (args.length < 2) throw new Error("least() expects at least 2 arguments");
|
|
10134
|
-
return
|
|
10193
|
+
return afn("LEAST", args);
|
|
10135
10194
|
};
|
|
10136
10195
|
var ifNull = (val, defaultValue) => coalesce(val, defaultValue);
|
|
10137
10196
|
|
|
@@ -10148,10 +10207,12 @@ var fn6 = (key, args) => ({
|
|
|
10148
10207
|
fn: key,
|
|
10149
10208
|
args: args.map(toOperand6)
|
|
10150
10209
|
});
|
|
10151
|
-
var
|
|
10152
|
-
var
|
|
10153
|
-
var
|
|
10154
|
-
var
|
|
10210
|
+
var nfn4 = (key, args) => asType(fn6(key, args));
|
|
10211
|
+
var afn2 = (key, args) => asType(fn6(key, args));
|
|
10212
|
+
var jsonLength = (target, path) => path === void 0 ? nfn4("JSON_LENGTH", [target]) : nfn4("JSON_LENGTH", [target, path]);
|
|
10213
|
+
var jsonSet = (target, path, value) => afn2("JSON_SET", [target, path, value]);
|
|
10214
|
+
var jsonArrayAgg = (value) => afn2("JSON_ARRAYAGG", [value]);
|
|
10215
|
+
var jsonContains = (target, candidate, path) => path === void 0 ? afn2("JSON_CONTAINS", [target, candidate]) : afn2("JSON_CONTAINS", [target, candidate, path]);
|
|
10155
10216
|
|
|
10156
10217
|
// src/core/functions/array.ts
|
|
10157
10218
|
var isColumnDef6 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
|
|
@@ -10166,7 +10227,8 @@ var fn7 = (key, args) => ({
|
|
|
10166
10227
|
fn: key,
|
|
10167
10228
|
args: args.map(toOperand7)
|
|
10168
10229
|
});
|
|
10169
|
-
var
|
|
10230
|
+
var afn3 = (key, args) => asType(fn7(key, args));
|
|
10231
|
+
var arrayAppend = (array, value) => afn3("ARRAY_APPEND", [array, value]);
|
|
10170
10232
|
|
|
10171
10233
|
// src/orm/als.ts
|
|
10172
10234
|
var AsyncLocalStorage = class {
|
|
@@ -12738,6 +12800,7 @@ export {
|
|
|
12738
12800
|
aliasRef,
|
|
12739
12801
|
and,
|
|
12740
12802
|
arrayAppend,
|
|
12803
|
+
asType,
|
|
12741
12804
|
ascii,
|
|
12742
12805
|
asin,
|
|
12743
12806
|
atan,
|
|
@@ -12803,6 +12866,8 @@ export {
|
|
|
12803
12866
|
eq,
|
|
12804
12867
|
esel,
|
|
12805
12868
|
executeHydrated,
|
|
12869
|
+
executeHydratedPlain,
|
|
12870
|
+
executeHydratedPlainWithContexts,
|
|
12806
12871
|
executeHydratedWithContexts,
|
|
12807
12872
|
executeSchemaSql,
|
|
12808
12873
|
executeSchemaSqlFor,
|