pqb 0.67.5 → 0.67.7
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 +510 -219
- package/dist/index.js +44 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +499 -223
- package/dist/internal.js +18 -0
- package/dist/internal.mjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2059,8 +2059,8 @@ var IntervalColumn = class extends Column {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
};
|
|
2061
2061
|
var ArrayColumn = class ArrayColumn extends Column {
|
|
2062
|
-
constructor(schema, item,
|
|
2063
|
-
super(schema,
|
|
2062
|
+
constructor(schema, item, __inputType, defaultEncode, __outputType, __queryType) {
|
|
2063
|
+
super(schema, __inputType, __outputType, __queryType);
|
|
2064
2064
|
this.dataType = "array";
|
|
2065
2065
|
this.operators = Operators.array;
|
|
2066
2066
|
item.data.isNullable = true;
|
|
@@ -2140,8 +2140,8 @@ const parsePostgresArray = (source, entries, transform) => {
|
|
|
2140
2140
|
};
|
|
2141
2141
|
const encodeJson = (x) => x === null ? x : JSON.stringify(x);
|
|
2142
2142
|
var JSONColumn = class extends Column {
|
|
2143
|
-
constructor(schema,
|
|
2144
|
-
super(schema,
|
|
2143
|
+
constructor(schema, __inputType, encodedByDriver = true) {
|
|
2144
|
+
super(schema, __inputType);
|
|
2145
2145
|
this.dataType = "jsonb";
|
|
2146
2146
|
this.operators = Operators.json;
|
|
2147
2147
|
if (!encodedByDriver) this.data.encode = encodeJson;
|
|
@@ -2153,10 +2153,10 @@ var JSONColumn = class extends Column {
|
|
|
2153
2153
|
};
|
|
2154
2154
|
var JSONTextColumn = class JSONTextColumn extends Column {
|
|
2155
2155
|
static get instance() {
|
|
2156
|
-
return this._instance ??= new JSONTextColumn(internalSchemaConfig);
|
|
2156
|
+
return this._instance ??= new JSONTextColumn(internalSchemaConfig, void 0);
|
|
2157
2157
|
}
|
|
2158
|
-
constructor(schema) {
|
|
2159
|
-
super(schema,
|
|
2158
|
+
constructor(schema, __inputType) {
|
|
2159
|
+
super(schema, __inputType);
|
|
2160
2160
|
this.dataType = "json";
|
|
2161
2161
|
this.operators = Operators.text;
|
|
2162
2162
|
}
|
|
@@ -2367,6 +2367,9 @@ const defaultSchemaConfig = (options) => {
|
|
|
2367
2367
|
json() {
|
|
2368
2368
|
return new JSONColumn(schemaConfig, void 0, options?.jsonEncodedByDriver);
|
|
2369
2369
|
},
|
|
2370
|
+
jsonText() {
|
|
2371
|
+
return new JSONTextColumn(schemaConfig, void 0);
|
|
2372
|
+
},
|
|
2370
2373
|
setErrors: noop,
|
|
2371
2374
|
smallint: () => new SmallIntColumn(schemaConfig),
|
|
2372
2375
|
integer: () => new IntegerColumn(schemaConfig),
|
|
@@ -2995,9 +2998,7 @@ const makeColumnTypes = (schema) => {
|
|
|
2995
2998
|
return new XMLColumn(schema);
|
|
2996
2999
|
},
|
|
2997
3000
|
json: schema.json,
|
|
2998
|
-
jsonText
|
|
2999
|
-
return new JSONTextColumn(schema);
|
|
3000
|
-
},
|
|
3001
|
+
jsonText: schema.jsonText,
|
|
3001
3002
|
type(dataType) {
|
|
3002
3003
|
return new CustomTypeColumn(schema, dataType);
|
|
3003
3004
|
},
|
|
@@ -9865,6 +9866,34 @@ const getSqlText = (sql) => {
|
|
|
9865
9866
|
if ("text" in sql) return sql.text;
|
|
9866
9867
|
throw new Error(`Batch SQL is not supported in this query`);
|
|
9867
9868
|
};
|
|
9869
|
+
const queryToSql = (query) => {
|
|
9870
|
+
const sql = query.toSQL();
|
|
9871
|
+
if ("batch" in sql) throw new OrchidOrmInternalError(query, "Batch SQL is not supported in query definitions");
|
|
9872
|
+
return sql;
|
|
9873
|
+
};
|
|
9874
|
+
const rawSqlToSql = (sql) => {
|
|
9875
|
+
if (typeof sql === "string") return { text: sql };
|
|
9876
|
+
const values = [];
|
|
9877
|
+
return {
|
|
9878
|
+
text: sql.toSQL({ values }),
|
|
9879
|
+
values
|
|
9880
|
+
};
|
|
9881
|
+
};
|
|
9882
|
+
const sqlToRawSql = (sql) => {
|
|
9883
|
+
const { values } = sql;
|
|
9884
|
+
if (!values?.length) return raw({ raw: sql.text });
|
|
9885
|
+
const rawValues = {};
|
|
9886
|
+
for (let i = 0; i < values.length; i++) rawValues[`queryValue${i + 1}`] = values[i];
|
|
9887
|
+
return raw({ raw: replaceSqlPlaceholders(sql.text, values.length) }).values(rawValues);
|
|
9888
|
+
};
|
|
9889
|
+
const replaceSqlPlaceholders = (sql, valuesCount) => {
|
|
9890
|
+
const parts = sql.split("'");
|
|
9891
|
+
for (let i = 0; i < parts.length; i += 2) parts[i] = parts[i].replace(/\$(\d+)/g, (match, index) => {
|
|
9892
|
+
const number = Number(index);
|
|
9893
|
+
return number > 0 && number <= valuesCount ? `$queryValue${number}` : match;
|
|
9894
|
+
});
|
|
9895
|
+
return parts.join("'");
|
|
9896
|
+
};
|
|
9868
9897
|
var QuerySql = class {
|
|
9869
9898
|
sql(...args) {
|
|
9870
9899
|
const sql = raw(...args);
|
|
@@ -11117,7 +11146,7 @@ const getShapeFromSelect = (q, isSubQuery) => {
|
|
|
11117
11146
|
if (returnType === "value" || returnType === "valueOrThrow") {
|
|
11118
11147
|
const type = it.q.getColumn;
|
|
11119
11148
|
result[key] = type ? mapSubSelectColumn(type, isSubQuery) : UnknownColumn.instance;
|
|
11120
|
-
} else result[key] = new JSONTextColumn(internalSchemaConfig);
|
|
11149
|
+
} else result[key] = new JSONTextColumn(internalSchemaConfig, void 0);
|
|
11121
11150
|
}
|
|
11122
11151
|
}
|
|
11123
11152
|
}
|
|
@@ -13917,6 +13946,7 @@ var Db = class extends QueryMethods {
|
|
|
13917
13946
|
comment: options.comment,
|
|
13918
13947
|
readOnly: options.readOnly,
|
|
13919
13948
|
materialized: options.materialized,
|
|
13949
|
+
generatorIgnored: options.generatorIgnore,
|
|
13920
13950
|
nowSQL: options.nowSQL,
|
|
13921
13951
|
viewData,
|
|
13922
13952
|
tableData,
|
|
@@ -14611,11 +14641,13 @@ exports.primaryKeyInnerToCode = primaryKeyInnerToCode;
|
|
|
14611
14641
|
exports.pushQueryOnForOuter = pushQueryOnForOuter;
|
|
14612
14642
|
exports.pushQueryValueImmutable = pushQueryValueImmutable;
|
|
14613
14643
|
exports.pushTableDataCode = pushTableDataCode;
|
|
14644
|
+
exports.queryToSql = queryToSql;
|
|
14614
14645
|
exports.quoteIdentifier = quoteIdentifier;
|
|
14615
14646
|
exports.quoteObjectKey = quoteObjectKey;
|
|
14616
14647
|
exports.quoteTableWithSchema = quoteTableWithSchema;
|
|
14617
14648
|
exports.raw = raw;
|
|
14618
14649
|
exports.rawSqlToCode = rawSqlToCode;
|
|
14650
|
+
exports.rawSqlToSql = rawSqlToSql;
|
|
14619
14651
|
exports.referencesArgsToCode = referencesArgsToCode;
|
|
14620
14652
|
exports.refreshMaterializedView = refreshMaterializedView;
|
|
14621
14653
|
exports.returnArg = returnArg;
|
|
@@ -14629,6 +14661,7 @@ exports.setDefaultLanguage = setDefaultLanguage;
|
|
|
14629
14661
|
exports.setFreeAlias = setFreeAlias;
|
|
14630
14662
|
exports.setQueryObjectValueImmutable = setQueryObjectValueImmutable;
|
|
14631
14663
|
exports.singleQuote = singleQuote;
|
|
14664
|
+
exports.sqlToRawSql = sqlToRawSql;
|
|
14632
14665
|
exports.tableDataMethods = tableDataMethods;
|
|
14633
14666
|
exports.testTransaction = testTransaction;
|
|
14634
14667
|
exports.toArray = toArray;
|