pqb 0.31.6 → 0.31.8
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/dist/index.d.ts +23 -6
- package/dist/index.js +325 -204
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +323 -205
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -834,6 +834,12 @@ const columnCode = (type, t, code, migration, data = type.data, skip) => {
|
|
|
834
834
|
return code.length === 1 && typeof code[0] === "string" ? code[0] : code;
|
|
835
835
|
};
|
|
836
836
|
|
|
837
|
+
const getSqlText = (sql) => {
|
|
838
|
+
if ("text" in sql)
|
|
839
|
+
return sql.text;
|
|
840
|
+
throw new Error(`Batch SQL is not supported in this query`);
|
|
841
|
+
};
|
|
842
|
+
|
|
837
843
|
var __defProp$f = Object.defineProperty;
|
|
838
844
|
var __defProps$7 = Object.defineProperties;
|
|
839
845
|
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
@@ -887,7 +893,7 @@ const quoteValue$1 = (arg, ctx, quotedAs, jsonArray) => {
|
|
|
887
893
|
return arg.toSQL(ctx, quotedAs);
|
|
888
894
|
}
|
|
889
895
|
if ("toSQL" in arg) {
|
|
890
|
-
return `(${arg.toSQL({ values: ctx.values })
|
|
896
|
+
return `(${getSqlText(arg.toSQL({ values: ctx.values }))})`;
|
|
891
897
|
}
|
|
892
898
|
}
|
|
893
899
|
return addValue(ctx.values, arg);
|
|
@@ -2070,7 +2076,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
2070
2076
|
if (query2.q.expr) {
|
|
2071
2077
|
const q = joinSubQuery(table, query2);
|
|
2072
2078
|
q.q.select = [query2.q.expr];
|
|
2073
|
-
ands.push(`(${makeSQL(q, ctx)
|
|
2079
|
+
ands.push(`(${getSqlText(makeSQL(q, ctx))})`);
|
|
2074
2080
|
} else {
|
|
2075
2081
|
pushWhereToSql(
|
|
2076
2082
|
ands,
|
|
@@ -2223,7 +2229,9 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
2223
2229
|
}
|
|
2224
2230
|
}
|
|
2225
2231
|
if (value instanceof ctx.queryBuilder.constructor) {
|
|
2226
|
-
ands.push(
|
|
2232
|
+
ands.push(
|
|
2233
|
+
`${quotedColumn} = (${getSqlText(value.toSQL(ctx))})`
|
|
2234
|
+
);
|
|
2227
2235
|
} else {
|
|
2228
2236
|
for (const op in value) {
|
|
2229
2237
|
const operator = column.operators[op];
|
|
@@ -2270,8 +2278,7 @@ const pushIn = (ctx, query, ands, quotedAs, arg) => {
|
|
|
2270
2278
|
} else if (isExpression(arg.values)) {
|
|
2271
2279
|
value = arg.values.toSQL(ctx, quotedAs);
|
|
2272
2280
|
} else {
|
|
2273
|
-
|
|
2274
|
-
value = `(${sql.text})`;
|
|
2281
|
+
value = `(${getSqlText(makeSQL(arg.values, ctx))})`;
|
|
2275
2282
|
}
|
|
2276
2283
|
const columnsSql = arg.columns.map((column) => columnToSql(ctx, query, query.shape, column, quotedAs)).join(", ");
|
|
2277
2284
|
ands.push(`${multiple ? `(${columnsSql})` : columnsSql} IN ${value}`);
|
|
@@ -2400,9 +2407,11 @@ const subJoinToSql = (ctx, jq, innerAs, outerAs, cloned) => {
|
|
|
2400
2407
|
jq = jq.clone();
|
|
2401
2408
|
jq.q.select = [new RawSQL(`${innerAs}.*`)];
|
|
2402
2409
|
}
|
|
2403
|
-
return `(${
|
|
2404
|
-
|
|
2405
|
-
|
|
2410
|
+
return `(${getSqlText(
|
|
2411
|
+
jq.toSQL({
|
|
2412
|
+
values: ctx.values
|
|
2413
|
+
})
|
|
2414
|
+
)}) ${outerAs || innerAs}`;
|
|
2406
2415
|
};
|
|
2407
2416
|
const processArgs = (args, ctx, query, joinAs, joinShape, quotedAs) => {
|
|
2408
2417
|
return args.length === 1 ? getObjectOrRawConditions(ctx, query, args[0], quotedAs, joinAs, joinShape) : getConditionsFor3Or4LengthItem(
|
|
@@ -2459,7 +2468,7 @@ const pushJoinSql = (ctx, table, query, quotedAs) => {
|
|
|
2459
2468
|
const { aliasValue } = ctx;
|
|
2460
2469
|
ctx.aliasValue = true;
|
|
2461
2470
|
const as = item[2];
|
|
2462
|
-
sql = `${item[0]} LATERAL (${q.toSQL(ctx)
|
|
2471
|
+
sql = `${item[0]} LATERAL (${getSqlText(q.toSQL(ctx))}) "${((_a = query.joinOverrides) == null ? void 0 : _a[as]) || as}" ON true`;
|
|
2463
2472
|
ctx.aliasValue = aliasValue;
|
|
2464
2473
|
} else {
|
|
2465
2474
|
const { target, on = "true" } = processJoinItem(
|
|
@@ -2985,6 +2994,104 @@ const defaultSchemaConfig = {
|
|
|
2985
2994
|
timestamp: (precision) => new TimestampTZColumn(defaultSchemaConfig, precision)
|
|
2986
2995
|
};
|
|
2987
2996
|
|
|
2997
|
+
const commitSql$1 = {
|
|
2998
|
+
text: "COMMIT"
|
|
2999
|
+
};
|
|
3000
|
+
const rollbackSql$1 = {
|
|
3001
|
+
text: "ROLLBACK"
|
|
3002
|
+
};
|
|
3003
|
+
class Transaction {
|
|
3004
|
+
async transaction(cbOrOptions, cb) {
|
|
3005
|
+
let options;
|
|
3006
|
+
let fn;
|
|
3007
|
+
if (typeof cbOrOptions === "function") {
|
|
3008
|
+
options = emptyObject;
|
|
3009
|
+
fn = cbOrOptions;
|
|
3010
|
+
} else {
|
|
3011
|
+
options = typeof cbOrOptions === "object" ? cbOrOptions : { level: cbOrOptions };
|
|
3012
|
+
fn = cb;
|
|
3013
|
+
}
|
|
3014
|
+
const sql = {
|
|
3015
|
+
values: emptyArray
|
|
3016
|
+
};
|
|
3017
|
+
const log = this.q.log;
|
|
3018
|
+
let logData;
|
|
3019
|
+
let trx = this.internal.transactionStorage.getStore();
|
|
3020
|
+
const transactionId = trx ? trx.transactionId + 1 : 0;
|
|
3021
|
+
const callback = (adapter) => {
|
|
3022
|
+
if (log)
|
|
3023
|
+
log.afterQuery(sql, logData);
|
|
3024
|
+
if (log)
|
|
3025
|
+
logData = log.beforeQuery(commitSql$1);
|
|
3026
|
+
if (trx) {
|
|
3027
|
+
trx.transactionId = transactionId;
|
|
3028
|
+
return fn();
|
|
3029
|
+
}
|
|
3030
|
+
trx = {
|
|
3031
|
+
adapter,
|
|
3032
|
+
transactionId
|
|
3033
|
+
};
|
|
3034
|
+
return this.internal.transactionStorage.run(trx, fn);
|
|
3035
|
+
};
|
|
3036
|
+
if (!trx) {
|
|
3037
|
+
sql.text = `BEGIN${options.level ? ` ISOLATION LEVEL ${options.level}` : ""}${options.readOnly !== void 0 ? ` READ ${options.readOnly ? "ONLY" : "WRITE"}` : ""}${options.deferrable !== void 0 ? ` ${options.deferrable ? "" : "NOT "}DEFERRABLE` : ""}`;
|
|
3038
|
+
if (log)
|
|
3039
|
+
logData = log.beforeQuery(sql);
|
|
3040
|
+
try {
|
|
3041
|
+
const result = await this.q.adapter.transaction(sql, callback);
|
|
3042
|
+
if (log)
|
|
3043
|
+
log.afterQuery(commitSql$1, logData);
|
|
3044
|
+
const { afterCommit } = trx;
|
|
3045
|
+
if (afterCommit) {
|
|
3046
|
+
const promises = [];
|
|
3047
|
+
for (let i = 0, len = afterCommit.length; i < len; i += 2) {
|
|
3048
|
+
const q = afterCommit[i];
|
|
3049
|
+
const result2 = afterCommit[i + 1];
|
|
3050
|
+
for (const fn2 of afterCommit[i + 2]) {
|
|
3051
|
+
promises.push(fn2(result2, q));
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
await Promise.all(promises);
|
|
3055
|
+
}
|
|
3056
|
+
return result;
|
|
3057
|
+
} catch (err) {
|
|
3058
|
+
if (log)
|
|
3059
|
+
log.afterQuery(rollbackSql$1, logData);
|
|
3060
|
+
throw err;
|
|
3061
|
+
}
|
|
3062
|
+
} else {
|
|
3063
|
+
try {
|
|
3064
|
+
sql.text = `SAVEPOINT "${transactionId}"`;
|
|
3065
|
+
if (log)
|
|
3066
|
+
logData = log.beforeQuery(sql);
|
|
3067
|
+
const { adapter } = trx;
|
|
3068
|
+
await adapter.query(sql);
|
|
3069
|
+
let result;
|
|
3070
|
+
try {
|
|
3071
|
+
result = await callback(adapter);
|
|
3072
|
+
} catch (err) {
|
|
3073
|
+
sql.text = `ROLLBACK TO SAVEPOINT "${transactionId}"`;
|
|
3074
|
+
if (log)
|
|
3075
|
+
logData = log.beforeQuery(sql);
|
|
3076
|
+
await adapter.query(sql);
|
|
3077
|
+
if (log)
|
|
3078
|
+
log.afterQuery(sql, logData);
|
|
3079
|
+
throw err;
|
|
3080
|
+
}
|
|
3081
|
+
sql.text = `RELEASE SAVEPOINT "${transactionId}"`;
|
|
3082
|
+
if (log)
|
|
3083
|
+
logData = log.beforeQuery(sql);
|
|
3084
|
+
await adapter.query(sql);
|
|
3085
|
+
if (log)
|
|
3086
|
+
log.afterQuery(sql, logData);
|
|
3087
|
+
return result;
|
|
3088
|
+
} finally {
|
|
3089
|
+
trx.transactionId = transactionId - 1;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
|
|
2988
3095
|
const queryMethodByReturnType = {
|
|
2989
3096
|
all: "query",
|
|
2990
3097
|
rows: "arrays",
|
|
@@ -3091,6 +3198,7 @@ let nameI = 0;
|
|
|
3091
3198
|
const callAfterHook = function(cb) {
|
|
3092
3199
|
return cb(this[0], this[1]);
|
|
3093
3200
|
};
|
|
3201
|
+
const beginSql = { text: "BEGIN" };
|
|
3094
3202
|
const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks, resolve, reject) => {
|
|
3095
3203
|
var _a;
|
|
3096
3204
|
const { q: query } = q;
|
|
@@ -3108,23 +3216,64 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
3108
3216
|
}
|
|
3109
3217
|
sql = q.toSQL();
|
|
3110
3218
|
const { hookSelect } = sql;
|
|
3111
|
-
if (query.autoPreparedStatements) {
|
|
3112
|
-
sql.name = queriesNames[sql.text] || (queriesNames[sql.text] = (nameI++).toString(36));
|
|
3113
|
-
}
|
|
3114
|
-
if (query.log) {
|
|
3115
|
-
logData = query.log.beforeQuery(sql);
|
|
3116
|
-
}
|
|
3117
3219
|
const { returnType = "all" } = query;
|
|
3118
3220
|
const returns = hookSelect ? "all" : returnType;
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3221
|
+
let result;
|
|
3222
|
+
let queryResult;
|
|
3223
|
+
if ("text" in sql) {
|
|
3224
|
+
if (query.autoPreparedStatements) {
|
|
3225
|
+
sql.name = queriesNames[sql.text] || (queriesNames[sql.text] = (nameI++).toString(36));
|
|
3226
|
+
}
|
|
3227
|
+
if (query.log) {
|
|
3228
|
+
logData = query.log.beforeQuery(sql);
|
|
3229
|
+
}
|
|
3230
|
+
queryResult = await adapter[hookSelect ? "query" : queryMethodByReturnType[returnType]](sql);
|
|
3231
|
+
if (query.patchResult) {
|
|
3232
|
+
await query.patchResult(q, queryResult);
|
|
3233
|
+
}
|
|
3234
|
+
if (query.log) {
|
|
3235
|
+
query.log.afterQuery(sql, logData);
|
|
3236
|
+
sql = void 0;
|
|
3237
|
+
}
|
|
3238
|
+
result = query.handleResult(q, returns, queryResult);
|
|
3239
|
+
} else {
|
|
3240
|
+
const queryMethod = hookSelect ? "query" : queryMethodByReturnType[returnType];
|
|
3241
|
+
if (!trx) {
|
|
3242
|
+
if (query.log)
|
|
3243
|
+
logData = query.log.beforeQuery(beginSql);
|
|
3244
|
+
await adapter.arrays(beginSql);
|
|
3245
|
+
if (query.log)
|
|
3246
|
+
query.log.afterQuery(beginSql, logData);
|
|
3247
|
+
}
|
|
3248
|
+
for (const item of sql.batch) {
|
|
3249
|
+
sql = item;
|
|
3250
|
+
if (query.log) {
|
|
3251
|
+
logData = query.log.beforeQuery(sql);
|
|
3252
|
+
}
|
|
3253
|
+
const result2 = await adapter[queryMethod](sql);
|
|
3254
|
+
if (queryResult) {
|
|
3255
|
+
queryResult.rowCount += result2.rowCount;
|
|
3256
|
+
queryResult.rows.push(...result2.rows);
|
|
3257
|
+
} else {
|
|
3258
|
+
queryResult = result2;
|
|
3259
|
+
}
|
|
3260
|
+
if (query.log) {
|
|
3261
|
+
query.log.afterQuery(sql, logData);
|
|
3262
|
+
sql = void 0;
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
if (!trx) {
|
|
3266
|
+
if (query.log)
|
|
3267
|
+
logData = query.log.beforeQuery(commitSql$1);
|
|
3268
|
+
await adapter.arrays(commitSql$1);
|
|
3269
|
+
if (query.log)
|
|
3270
|
+
query.log.afterQuery(commitSql$1, logData);
|
|
3271
|
+
}
|
|
3272
|
+
if (query.patchResult) {
|
|
3273
|
+
await query.patchResult(q, queryResult);
|
|
3274
|
+
}
|
|
3275
|
+
result = query.handleResult(q, returns, queryResult);
|
|
3126
3276
|
}
|
|
3127
|
-
let result = query.handleResult(q, returns, queryResult);
|
|
3128
3277
|
if (afterHooks || afterCommitHooks || query.after) {
|
|
3129
3278
|
if (queryResult.rowCount) {
|
|
3130
3279
|
if (afterHooks || query.after) {
|
|
@@ -4027,7 +4176,7 @@ const pushSubQuerySql = (ctx, query, as, list, quotedAs) => {
|
|
|
4027
4176
|
`${coalesce(
|
|
4028
4177
|
ctx,
|
|
4029
4178
|
query,
|
|
4030
|
-
`(${makeSQL(query, ctx)
|
|
4179
|
+
`(${getSqlText(makeSQL(query, ctx))})`,
|
|
4031
4180
|
quotedAs
|
|
4032
4181
|
)} "${as}"`
|
|
4033
4182
|
);
|
|
@@ -4110,7 +4259,7 @@ const pushWithSql = (ctx, items) => {
|
|
|
4110
4259
|
var _a;
|
|
4111
4260
|
let inner;
|
|
4112
4261
|
if (item.q) {
|
|
4113
|
-
inner = makeSQL(item.q, ctx)
|
|
4262
|
+
inner = getSqlText(makeSQL(item.q, ctx));
|
|
4114
4263
|
} else {
|
|
4115
4264
|
inner = item.s.toSQL(ctx, `"${item.n}"`);
|
|
4116
4265
|
}
|
|
@@ -4204,9 +4353,9 @@ const fromToSql = (ctx, data, from, quotedAs) => {
|
|
|
4204
4353
|
} else {
|
|
4205
4354
|
only = from.q.only;
|
|
4206
4355
|
if (!from.table) {
|
|
4207
|
-
sql = `(${makeSQL(from, ctx)
|
|
4356
|
+
sql = `(${getSqlText(makeSQL(from, ctx))})`;
|
|
4208
4357
|
} else if (!checkIfASimpleQuery(from)) {
|
|
4209
|
-
sql = `(${makeSQL(from, ctx)
|
|
4358
|
+
sql = `(${getSqlText(makeSQL(from, ctx))})`;
|
|
4210
4359
|
} else {
|
|
4211
4360
|
sql = quoteSchemaAndTable(from.q.schema, from.table);
|
|
4212
4361
|
}
|
|
@@ -4274,8 +4423,10 @@ const getTsVector = (ctx, data, lang, source, quotedAs) => {
|
|
|
4274
4423
|
}
|
|
4275
4424
|
};
|
|
4276
4425
|
|
|
4426
|
+
const MAX_BINDING_PARAMS = 65536;
|
|
4427
|
+
|
|
4277
4428
|
const quotedColumns = [];
|
|
4278
|
-
const
|
|
4429
|
+
const makeInsertSql = (ctx, q, query, quotedAs) => {
|
|
4279
4430
|
var _a, _b, _c, _d;
|
|
4280
4431
|
const { columns, shape } = query;
|
|
4281
4432
|
quotedColumns.length = columns.length;
|
|
@@ -4302,59 +4453,11 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
4302
4453
|
values = [[void 0]];
|
|
4303
4454
|
}
|
|
4304
4455
|
}
|
|
4305
|
-
ctx.sql.push(
|
|
4456
|
+
ctx.sql.push(
|
|
4457
|
+
`INSERT INTO ${quotedAs}(${quotedColumns.join(", ")})`,
|
|
4458
|
+
null
|
|
4459
|
+
);
|
|
4306
4460
|
const QueryClass = ctx.queryBuilder.constructor;
|
|
4307
|
-
if (query.kind === "object") {
|
|
4308
|
-
let sql = "";
|
|
4309
|
-
for (let i = 0; i < values.length; i++) {
|
|
4310
|
-
if (i)
|
|
4311
|
-
sql += ", ";
|
|
4312
|
-
sql += `(${encodeRow(
|
|
4313
|
-
ctx,
|
|
4314
|
-
q,
|
|
4315
|
-
QueryClass,
|
|
4316
|
-
values[i],
|
|
4317
|
-
runtimeDefaults,
|
|
4318
|
-
quotedAs
|
|
4319
|
-
)})`;
|
|
4320
|
-
}
|
|
4321
|
-
ctx.sql.push(`VALUES ${sql}`);
|
|
4322
|
-
} else if (query.kind === "raw") {
|
|
4323
|
-
if (isExpression(values)) {
|
|
4324
|
-
let valuesSql = values.toSQL(ctx, quotedAs);
|
|
4325
|
-
if (runtimeDefaults) {
|
|
4326
|
-
valuesSql += `, ${runtimeDefaults.map((fn) => addValue(ctx.values, fn())).join(", ")}`;
|
|
4327
|
-
}
|
|
4328
|
-
ctx.sql.push(`VALUES (${valuesSql})`);
|
|
4329
|
-
} else {
|
|
4330
|
-
let sql;
|
|
4331
|
-
if (runtimeDefaults) {
|
|
4332
|
-
const { values: v } = ctx;
|
|
4333
|
-
sql = values.map(
|
|
4334
|
-
(raw) => (
|
|
4335
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
4336
|
-
`(${raw.toSQL(ctx, quotedAs)}, ${runtimeDefaults.map((fn) => addValue(v, fn())).join(", ")})`
|
|
4337
|
-
)
|
|
4338
|
-
).join(", ");
|
|
4339
|
-
} else {
|
|
4340
|
-
sql = values.map((raw) => `(${raw.toSQL(ctx, quotedAs)})`).join(", ");
|
|
4341
|
-
}
|
|
4342
|
-
ctx.sql.push(`VALUES ${sql}`);
|
|
4343
|
-
}
|
|
4344
|
-
} else {
|
|
4345
|
-
const { from, values: v } = values;
|
|
4346
|
-
const q2 = from.clone();
|
|
4347
|
-
if (v) {
|
|
4348
|
-
pushQueryValue(
|
|
4349
|
-
q2,
|
|
4350
|
-
"select",
|
|
4351
|
-
new RawSQL(
|
|
4352
|
-
encodeRow(ctx, q2, QueryClass, v[0], runtimeDefaults, quotedAs)
|
|
4353
|
-
)
|
|
4354
|
-
);
|
|
4355
|
-
}
|
|
4356
|
-
ctx.sql.push(makeSQL(q2, { values: ctx.values }).text);
|
|
4357
|
-
}
|
|
4358
4461
|
if (query.onConflict) {
|
|
4359
4462
|
ctx.sql.push("ON CONFLICT");
|
|
4360
4463
|
const { target } = query.onConflict;
|
|
@@ -4383,20 +4486,20 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
4383
4486
|
if (merge) {
|
|
4384
4487
|
if (typeof merge === "string") {
|
|
4385
4488
|
const name = ((_c = shape[merge]) == null ? void 0 : _c.data.name) || merge;
|
|
4386
|
-
sql = `"${name}" = excluded."${name}"`;
|
|
4489
|
+
sql = `DO UPDATE SET "${name}" = excluded."${name}"`;
|
|
4387
4490
|
} else if ("except" in merge) {
|
|
4388
4491
|
sql = mergeColumnsSql(columns, quotedColumns, target, merge.except);
|
|
4389
4492
|
} else {
|
|
4390
|
-
sql = merge.reduce((sql2, item, i) => {
|
|
4493
|
+
sql = `DO UPDATE SET ${merge.reduce((sql2, item, i) => {
|
|
4391
4494
|
var _a2;
|
|
4392
4495
|
const name = ((_a2 = shape[item]) == null ? void 0 : _a2.data.name) || item;
|
|
4393
4496
|
return sql2 + (i ? ", " : "") + `"${name}" = excluded."${name}"`;
|
|
4394
|
-
}, "")
|
|
4497
|
+
}, "")}`;
|
|
4395
4498
|
}
|
|
4396
4499
|
} else {
|
|
4397
4500
|
sql = mergeColumnsSql(columns, quotedColumns, target);
|
|
4398
4501
|
}
|
|
4399
|
-
ctx.sql.push(
|
|
4502
|
+
ctx.sql.push(sql);
|
|
4400
4503
|
} else if (query.onConflict.set) {
|
|
4401
4504
|
let sql;
|
|
4402
4505
|
const { set } = query.onConflict;
|
|
@@ -4420,7 +4523,111 @@ const pushInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
4420
4523
|
}
|
|
4421
4524
|
}
|
|
4422
4525
|
pushWhereStatementSql(ctx, q, query, quotedAs);
|
|
4423
|
-
|
|
4526
|
+
const hookSelect = pushReturningSql(
|
|
4527
|
+
ctx,
|
|
4528
|
+
q,
|
|
4529
|
+
query,
|
|
4530
|
+
quotedAs,
|
|
4531
|
+
query.afterCreateSelect
|
|
4532
|
+
);
|
|
4533
|
+
if (query.kind === "object") {
|
|
4534
|
+
const valuesSql = [];
|
|
4535
|
+
let ctxValues = ctx.values;
|
|
4536
|
+
const restValuesLen = ctxValues.length;
|
|
4537
|
+
let currentValuesLen = restValuesLen;
|
|
4538
|
+
let batch;
|
|
4539
|
+
for (let i = 0; i < values.length; i++) {
|
|
4540
|
+
const encodedRow = `(${encodeRow(
|
|
4541
|
+
ctx,
|
|
4542
|
+
ctxValues,
|
|
4543
|
+
q,
|
|
4544
|
+
QueryClass,
|
|
4545
|
+
values[i],
|
|
4546
|
+
runtimeDefaults,
|
|
4547
|
+
quotedAs
|
|
4548
|
+
)})`;
|
|
4549
|
+
if (ctxValues.length > MAX_BINDING_PARAMS) {
|
|
4550
|
+
if (ctxValues.length - currentValuesLen > MAX_BINDING_PARAMS) {
|
|
4551
|
+
throw new Error(
|
|
4552
|
+
`Too many parameters for a single insert row, max is ${MAX_BINDING_PARAMS}`
|
|
4553
|
+
);
|
|
4554
|
+
}
|
|
4555
|
+
ctx.sql[1] = `VALUES ${valuesSql.join(",")}`;
|
|
4556
|
+
ctxValues.length = currentValuesLen;
|
|
4557
|
+
batch = pushOrNewArray(batch, {
|
|
4558
|
+
text: ctx.sql.join(" "),
|
|
4559
|
+
values: ctxValues
|
|
4560
|
+
});
|
|
4561
|
+
ctxValues = ctx.values = [];
|
|
4562
|
+
valuesSql.length = 0;
|
|
4563
|
+
i--;
|
|
4564
|
+
} else {
|
|
4565
|
+
currentValuesLen = ctxValues.length;
|
|
4566
|
+
valuesSql.push(encodedRow);
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
if (batch) {
|
|
4570
|
+
ctx.sql[1] = `VALUES ${valuesSql.join(",")}`;
|
|
4571
|
+
batch.push({
|
|
4572
|
+
text: ctx.sql.join(" "),
|
|
4573
|
+
values: ctxValues
|
|
4574
|
+
});
|
|
4575
|
+
return {
|
|
4576
|
+
hookSelect,
|
|
4577
|
+
batch
|
|
4578
|
+
};
|
|
4579
|
+
} else {
|
|
4580
|
+
ctx.sql[1] = `VALUES ${valuesSql.join(", ")}`;
|
|
4581
|
+
}
|
|
4582
|
+
} else if (query.kind === "raw") {
|
|
4583
|
+
if (isExpression(values)) {
|
|
4584
|
+
let valuesSql = values.toSQL(ctx, quotedAs);
|
|
4585
|
+
if (runtimeDefaults) {
|
|
4586
|
+
valuesSql += `, ${runtimeDefaults.map((fn) => addValue(ctx.values, fn())).join(", ")}`;
|
|
4587
|
+
}
|
|
4588
|
+
ctx.sql[1] = `VALUES (${valuesSql})`;
|
|
4589
|
+
} else {
|
|
4590
|
+
let sql;
|
|
4591
|
+
if (runtimeDefaults) {
|
|
4592
|
+
const { values: v } = ctx;
|
|
4593
|
+
sql = values.map(
|
|
4594
|
+
(raw) => (
|
|
4595
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
4596
|
+
`(${raw.toSQL(ctx, quotedAs)}, ${runtimeDefaults.map((fn) => addValue(v, fn())).join(", ")})`
|
|
4597
|
+
)
|
|
4598
|
+
).join(", ");
|
|
4599
|
+
} else {
|
|
4600
|
+
sql = values.map((raw) => `(${raw.toSQL(ctx, quotedAs)})`).join(", ");
|
|
4601
|
+
}
|
|
4602
|
+
ctx.sql[1] = `VALUES ${sql}`;
|
|
4603
|
+
}
|
|
4604
|
+
} else {
|
|
4605
|
+
const { from, values: v } = values;
|
|
4606
|
+
const q2 = from.clone();
|
|
4607
|
+
if (v) {
|
|
4608
|
+
pushQueryValue(
|
|
4609
|
+
q2,
|
|
4610
|
+
"select",
|
|
4611
|
+
new RawSQL(
|
|
4612
|
+
encodeRow(
|
|
4613
|
+
ctx,
|
|
4614
|
+
ctx.values,
|
|
4615
|
+
q2,
|
|
4616
|
+
QueryClass,
|
|
4617
|
+
v[0],
|
|
4618
|
+
runtimeDefaults,
|
|
4619
|
+
quotedAs
|
|
4620
|
+
)
|
|
4621
|
+
)
|
|
4622
|
+
);
|
|
4623
|
+
}
|
|
4624
|
+
ctx.sql[1] = getSqlText(makeSQL(q2, { values: ctx.values }));
|
|
4625
|
+
}
|
|
4626
|
+
return {
|
|
4627
|
+
hookSelect,
|
|
4628
|
+
text: ctx.sql.join(" "),
|
|
4629
|
+
values: ctx.values
|
|
4630
|
+
};
|
|
4424
4631
|
};
|
|
4425
4632
|
const mergeColumnsSql = (columns, quotedColumns2, target, except) => {
|
|
4426
4633
|
const notExcluded = [];
|
|
@@ -4437,22 +4644,22 @@ const mergeColumnsSql = (columns, quotedColumns2, target, except) => {
|
|
|
4437
4644
|
notExcluded.push(quotedColumns2[i]);
|
|
4438
4645
|
}
|
|
4439
4646
|
}
|
|
4440
|
-
return notExcluded.map((column) => `${column} = excluded.${column}`).join(", ");
|
|
4647
|
+
return notExcluded.length ? `DO UPDATE SET ${notExcluded.map((column) => `${column} = excluded.${column}`).join(", ")}` : "DO NOTHING";
|
|
4441
4648
|
};
|
|
4442
|
-
const encodeRow = (ctx, q, QueryClass, row, runtimeDefaults, quotedAs) => {
|
|
4649
|
+
const encodeRow = (ctx, values, q, QueryClass, row, runtimeDefaults, quotedAs) => {
|
|
4443
4650
|
const arr = row.map((value) => {
|
|
4444
4651
|
if (value && typeof value === "object") {
|
|
4445
4652
|
if (value instanceof Expression) {
|
|
4446
4653
|
return value.toSQL(ctx, quotedAs);
|
|
4447
4654
|
} else if (value instanceof QueryClass) {
|
|
4448
|
-
return `(${joinSubQuery(q, value).toSQL(ctx)
|
|
4655
|
+
return `(${getSqlText(joinSubQuery(q, value).toSQL(ctx))})`;
|
|
4449
4656
|
}
|
|
4450
4657
|
}
|
|
4451
|
-
return value === void 0 ? "DEFAULT" : addValue(
|
|
4658
|
+
return value === void 0 ? "DEFAULT" : addValue(values, value);
|
|
4452
4659
|
});
|
|
4453
4660
|
if (runtimeDefaults) {
|
|
4454
4661
|
for (const fn of runtimeDefaults) {
|
|
4455
|
-
arr.push(addValue(
|
|
4662
|
+
arr.push(addValue(values, fn()));
|
|
4456
4663
|
}
|
|
4457
4664
|
}
|
|
4458
4665
|
return arr.join(", ");
|
|
@@ -4566,7 +4773,9 @@ const processValue = (ctx, table, QueryClass, key, value, quotedAs) => {
|
|
|
4566
4773
|
} else if (isExpression(value)) {
|
|
4567
4774
|
return value.toSQL(ctx, quotedAs);
|
|
4568
4775
|
} else if (value instanceof QueryClass) {
|
|
4569
|
-
return `(${
|
|
4776
|
+
return `(${getSqlText(
|
|
4777
|
+
joinSubQuery(table, value).toSQL(ctx)
|
|
4778
|
+
)})`;
|
|
4570
4779
|
} else if ("op" in value && "arg" in value) {
|
|
4571
4780
|
return `"${table.q.shape[key].data.name || key}" ${value.op} ${addValue(ctx.values, value.arg)}`;
|
|
4572
4781
|
}
|
|
@@ -4593,7 +4802,7 @@ const pushDeleteSql = (ctx, table, query, quotedAs) => {
|
|
|
4593
4802
|
ctx.aliasValue = true;
|
|
4594
4803
|
const as = item[2];
|
|
4595
4804
|
targets.push(
|
|
4596
|
-
`LATERAL (${q.toSQL(ctx)
|
|
4805
|
+
`LATERAL (${getSqlText(q.toSQL(ctx))}) "${((_b = query.joinOverrides) == null ? void 0 : _b[as]) || as}"`
|
|
4597
4806
|
);
|
|
4598
4807
|
ctx.aliasValue = aliasValue;
|
|
4599
4808
|
} else {
|
|
@@ -4770,11 +4979,7 @@ const makeSQL = (table, options) => {
|
|
|
4770
4979
|
}
|
|
4771
4980
|
const quotedAs2 = `"${query.as || tableName}"`;
|
|
4772
4981
|
if (query.type === "insert") {
|
|
4773
|
-
return {
|
|
4774
|
-
hookSelect: pushInsertSql(ctx, table, query, `"${tableName}"`),
|
|
4775
|
-
text: sql.join(" "),
|
|
4776
|
-
values
|
|
4777
|
-
};
|
|
4982
|
+
return makeInsertSql(ctx, table, query, `"${tableName}"`);
|
|
4778
4983
|
}
|
|
4779
4984
|
if (query.type === "update") {
|
|
4780
4985
|
return {
|
|
@@ -4797,9 +5002,9 @@ const makeSQL = (table, options) => {
|
|
|
4797
5002
|
}
|
|
4798
5003
|
const quotedAs = (query.as || table.table) && `"${query.as || table.table}"`;
|
|
4799
5004
|
if (query.union) {
|
|
4800
|
-
sql.push(`(${makeSQL(query.union.b, { values })
|
|
5005
|
+
sql.push(`(${getSqlText(makeSQL(query.union.b, { values }))})`);
|
|
4801
5006
|
for (const u of query.union.u) {
|
|
4802
|
-
const itemSql = isExpression(u.a) ? u.a.toSQL(ctx, quotedAs) : makeSQL(u.a, { values })
|
|
5007
|
+
const itemSql = isExpression(u.a) ? u.a.toSQL(ctx, quotedAs) : getSqlText(makeSQL(u.a, { values }));
|
|
4803
5008
|
sql.push(`${u.k} (${itemSql})`);
|
|
4804
5009
|
}
|
|
4805
5010
|
} else {
|
|
@@ -5289,8 +5494,8 @@ for (const key in types.builtins) {
|
|
|
5289
5494
|
delete defaultTypeParsers[id];
|
|
5290
5495
|
});
|
|
5291
5496
|
const returnArg = (arg) => arg;
|
|
5292
|
-
const rollbackSql
|
|
5293
|
-
const commitSql
|
|
5497
|
+
const rollbackSql = { text: "ROLLBACK" };
|
|
5498
|
+
const commitSql = { text: "COMMIT" };
|
|
5294
5499
|
class Adapter {
|
|
5295
5500
|
constructor(_a) {
|
|
5296
5501
|
var _b = _a, { types: types2 = defaultTypeParsers } = _b, config = __objRest$1(_b, ["types"]);
|
|
@@ -5332,7 +5537,7 @@ class Adapter {
|
|
|
5332
5537
|
arrays(query, types2) {
|
|
5333
5538
|
return performQuery$1(this, query, types2, "array");
|
|
5334
5539
|
}
|
|
5335
|
-
async transaction(begin, cb, end = commitSql
|
|
5540
|
+
async transaction(begin, cb, end = commitSql) {
|
|
5336
5541
|
const client = await this.connect();
|
|
5337
5542
|
try {
|
|
5338
5543
|
await setSearchPath(client, this.schema);
|
|
@@ -5341,7 +5546,7 @@ class Adapter {
|
|
|
5341
5546
|
try {
|
|
5342
5547
|
result = await cb(new TransactionAdapter(this, client, this.types));
|
|
5343
5548
|
} catch (err) {
|
|
5344
|
-
await performQueryOnClient(client, rollbackSql
|
|
5549
|
+
await performQueryOnClient(client, rollbackSql, this.types);
|
|
5345
5550
|
throw err;
|
|
5346
5551
|
}
|
|
5347
5552
|
await performQueryOnClient(client, end, this.types);
|
|
@@ -6447,6 +6652,19 @@ class Create {
|
|
|
6447
6652
|
* const createdCount = await db.table.insertMany([data, data, data]);
|
|
6448
6653
|
* ```
|
|
6449
6654
|
*
|
|
6655
|
+
* Because of a limitation of Postgres protocol, queries having more than **65536** are going to fail in runtime.
|
|
6656
|
+
* To solve this seamlessly, OrchidORM will automatically batch such queries, and wrap them into a transaction, unless they are already in a transaction.
|
|
6657
|
+
*
|
|
6658
|
+
* ```ts
|
|
6659
|
+
* // OK: executes 2 inserts wrapped into a transaction
|
|
6660
|
+
* await db.table.createMany(
|
|
6661
|
+
* Array.from({ length: 65536 }, () => ({ text: 'text' })),
|
|
6662
|
+
* );
|
|
6663
|
+
* ```
|
|
6664
|
+
*
|
|
6665
|
+
* However, this only works in the case shown above. This **won't** work if you're using the `createMany` in `with` statement,
|
|
6666
|
+
* or if the insert is used as a sub-query in other query part.
|
|
6667
|
+
*
|
|
6450
6668
|
* @param data - array of records data, may have values, raw SQL, queries, relation operations
|
|
6451
6669
|
*/
|
|
6452
6670
|
createMany(data) {
|
|
@@ -9828,106 +10046,6 @@ class Update {
|
|
|
9828
10046
|
}
|
|
9829
10047
|
}
|
|
9830
10048
|
|
|
9831
|
-
const commitSql = {
|
|
9832
|
-
text: "COMMIT",
|
|
9833
|
-
values: emptyArray
|
|
9834
|
-
};
|
|
9835
|
-
const rollbackSql = {
|
|
9836
|
-
text: "ROLLBACK",
|
|
9837
|
-
values: emptyArray
|
|
9838
|
-
};
|
|
9839
|
-
class Transaction {
|
|
9840
|
-
async transaction(cbOrOptions, cb) {
|
|
9841
|
-
let options;
|
|
9842
|
-
let fn;
|
|
9843
|
-
if (typeof cbOrOptions === "function") {
|
|
9844
|
-
options = emptyObject;
|
|
9845
|
-
fn = cbOrOptions;
|
|
9846
|
-
} else {
|
|
9847
|
-
options = typeof cbOrOptions === "object" ? cbOrOptions : { level: cbOrOptions };
|
|
9848
|
-
fn = cb;
|
|
9849
|
-
}
|
|
9850
|
-
const sql = {
|
|
9851
|
-
values: emptyArray
|
|
9852
|
-
};
|
|
9853
|
-
const log = this.q.log;
|
|
9854
|
-
let logData;
|
|
9855
|
-
let trx = this.internal.transactionStorage.getStore();
|
|
9856
|
-
const transactionId = trx ? trx.transactionId + 1 : 0;
|
|
9857
|
-
const callback = (adapter) => {
|
|
9858
|
-
if (log)
|
|
9859
|
-
log.afterQuery(sql, logData);
|
|
9860
|
-
if (log)
|
|
9861
|
-
logData = log.beforeQuery(commitSql);
|
|
9862
|
-
if (trx) {
|
|
9863
|
-
trx.transactionId = transactionId;
|
|
9864
|
-
return fn();
|
|
9865
|
-
}
|
|
9866
|
-
trx = {
|
|
9867
|
-
adapter,
|
|
9868
|
-
transactionId
|
|
9869
|
-
};
|
|
9870
|
-
return this.internal.transactionStorage.run(trx, fn);
|
|
9871
|
-
};
|
|
9872
|
-
if (!trx) {
|
|
9873
|
-
sql.text = `BEGIN${options.level ? ` ISOLATION LEVEL ${options.level}` : ""}${options.readOnly !== void 0 ? ` READ ${options.readOnly ? "ONLY" : "WRITE"}` : ""}${options.deferrable !== void 0 ? ` ${options.deferrable ? "" : "NOT "}DEFERRABLE` : ""}`;
|
|
9874
|
-
if (log)
|
|
9875
|
-
logData = log.beforeQuery(sql);
|
|
9876
|
-
try {
|
|
9877
|
-
const result = await this.q.adapter.transaction(sql, callback);
|
|
9878
|
-
if (log)
|
|
9879
|
-
log.afterQuery(commitSql, logData);
|
|
9880
|
-
const { afterCommit } = trx;
|
|
9881
|
-
if (afterCommit) {
|
|
9882
|
-
const promises = [];
|
|
9883
|
-
for (let i = 0, len = afterCommit.length; i < len; i += 2) {
|
|
9884
|
-
const q = afterCommit[i];
|
|
9885
|
-
const result2 = afterCommit[i + 1];
|
|
9886
|
-
for (const fn2 of afterCommit[i + 2]) {
|
|
9887
|
-
promises.push(fn2(result2, q));
|
|
9888
|
-
}
|
|
9889
|
-
}
|
|
9890
|
-
await Promise.all(promises);
|
|
9891
|
-
}
|
|
9892
|
-
return result;
|
|
9893
|
-
} catch (err) {
|
|
9894
|
-
if (log)
|
|
9895
|
-
log.afterQuery(rollbackSql, logData);
|
|
9896
|
-
throw err;
|
|
9897
|
-
}
|
|
9898
|
-
} else {
|
|
9899
|
-
try {
|
|
9900
|
-
sql.text = `SAVEPOINT "${transactionId}"`;
|
|
9901
|
-
if (log)
|
|
9902
|
-
logData = log.beforeQuery(sql);
|
|
9903
|
-
const { adapter } = trx;
|
|
9904
|
-
await adapter.query(sql);
|
|
9905
|
-
let result;
|
|
9906
|
-
try {
|
|
9907
|
-
result = await callback(adapter);
|
|
9908
|
-
} catch (err) {
|
|
9909
|
-
sql.text = `ROLLBACK TO SAVEPOINT "${transactionId}"`;
|
|
9910
|
-
if (log)
|
|
9911
|
-
logData = log.beforeQuery(sql);
|
|
9912
|
-
await adapter.query(sql);
|
|
9913
|
-
if (log)
|
|
9914
|
-
log.afterQuery(sql, logData);
|
|
9915
|
-
throw err;
|
|
9916
|
-
}
|
|
9917
|
-
sql.text = `RELEASE SAVEPOINT "${transactionId}"`;
|
|
9918
|
-
if (log)
|
|
9919
|
-
logData = log.beforeQuery(sql);
|
|
9920
|
-
await adapter.query(sql);
|
|
9921
|
-
if (log)
|
|
9922
|
-
log.afterQuery(sql, logData);
|
|
9923
|
-
return result;
|
|
9924
|
-
} finally {
|
|
9925
|
-
trx.transactionId = transactionId - 1;
|
|
9926
|
-
}
|
|
9927
|
-
}
|
|
9928
|
-
}
|
|
9929
|
-
}
|
|
9930
|
-
|
|
9931
10049
|
var __defProp$2 = Object.defineProperty;
|
|
9932
10050
|
var __defProps = Object.defineProperties;
|
|
9933
10051
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -10602,7 +10720,7 @@ class OrExpression extends Expression {
|
|
|
10602
10720
|
if (sql)
|
|
10603
10721
|
res.push(sql);
|
|
10604
10722
|
} else {
|
|
10605
|
-
res.push(`(${arg.toSQL(ctx)
|
|
10723
|
+
res.push(`(${getSqlText(arg.toSQL(ctx))})`);
|
|
10606
10724
|
}
|
|
10607
10725
|
}
|
|
10608
10726
|
}
|
|
@@ -12016,5 +12134,5 @@ function copyTableData(query, arg) {
|
|
|
12016
12134
|
return q;
|
|
12017
12135
|
}
|
|
12018
12136
|
|
|
12019
|
-
export { Adapter, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, JsonModifiers, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, XMLColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotSql, _queryWhereSql, addComputedColumns, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseResult, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
12137
|
+
export { Adapter, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CharColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, JsonModifiers, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, XMLColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotSql, _queryWhereSql, addComputedColumns, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, extendQuery, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logColors, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseResult, parseTableData, parseTableDataInput, primaryKeyInnerToCode, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, quote, quoteString, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql$1 as rollbackSql, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
12020
12138
|
//# sourceMappingURL=index.mjs.map
|