@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.
Files changed (2) hide show
  1. package/orm/sqls/sqls.js +5 -5
  2. 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 `${value}`;
408
+ return sql `to_jsonb(${value})`;
409
409
  }
410
- if (isNull(value)) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.93.109",
3
+ "version": "0.93.110",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"