@tstdl/base 0.93.109 → 0.93.110
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/orm/sqls/sqls.js +5 -5
- package/package.json +1 -1
package/orm/sqls/sqls.js
CHANGED
|
@@ -8,7 +8,7 @@ import { and, Column, eq, isSQLWrapper, sql, isNotNull as sqlIsNotNull, isNull a
|
|
|
8
8
|
import { match, P } from 'ts-pattern';
|
|
9
9
|
import { distinct, toArray } from '../../utils/array/array.js';
|
|
10
10
|
import { objectEntries, objectValues } from '../../utils/object/object.js';
|
|
11
|
-
import { assertDefined, isArray, isBoolean, isDefined, isInstanceOf, isNotNull, isNull, isNumber, isObject, isString } from '../../utils/type-guards.js';
|
|
11
|
+
import { assertDefined, isArray, isBoolean, isDefined, isInstanceOf, isNotNull, isNull, isNullOrUndefined, isNumber, isObject, isString } from '../../utils/type-guards.js';
|
|
12
12
|
import { getEnumName } from '../enums.js';
|
|
13
13
|
import { caseWhen } from './case-when.js';
|
|
14
14
|
export const simpleJsonKeyPattern = /^[a-zA-Z0-9_-]+$/u;
|
|
@@ -405,10 +405,10 @@ export function jsonbBuildObject(properties) {
|
|
|
405
405
|
*/
|
|
406
406
|
export function buildJsonb(value) {
|
|
407
407
|
if (isSQLWrapper(value)) {
|
|
408
|
-
return sql
|
|
408
|
+
return sql `to_jsonb(${value})`;
|
|
409
409
|
}
|
|
410
|
-
if (
|
|
411
|
-
return sql `null`;
|
|
410
|
+
if (isNullOrUndefined(value)) {
|
|
411
|
+
return sql `'null'::jsonb`;
|
|
412
412
|
}
|
|
413
413
|
if (isArray(value)) {
|
|
414
414
|
if (value.length == 0) {
|
|
@@ -420,5 +420,5 @@ export function buildJsonb(value) {
|
|
|
420
420
|
if (isObject(value)) {
|
|
421
421
|
return jsonbBuildObject(value);
|
|
422
422
|
}
|
|
423
|
-
return sql `${value}`;
|
|
423
|
+
return sql `${JSON.stringify(value)}::jsonb`;
|
|
424
424
|
}
|