@saltcorn/db-common
Advanced tools
Comparing version 0.9.6-beta.11 to 0.9.6-beta.12
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
export declare const reprAsJson: (v: any) => boolean; | ||
export declare const reprAsJson: (v: any, jsonCol?: boolean) => boolean; | ||
/** | ||
@@ -20,3 +20,3 @@ * @param opts | ||
*/ | ||
export declare const mkVal: ([k, v]: [string, any]) => Value; | ||
export declare const mkVal: ([k, v]: [string, any], jsonCol?: boolean) => Value; | ||
/** | ||
@@ -41,2 +41,3 @@ * return type of buildInsertSql() | ||
replace?: boolean; | ||
jsonCols?: string[]; | ||
}) => SqlAndValues; | ||
@@ -43,0 +44,0 @@ declare type SqlAndValuesBulk = { |
@@ -15,3 +15,4 @@ "use strict"; | ||
*/ | ||
const reprAsJson = (v) => typeof v === "object" && v !== null && !(v instanceof Date); | ||
const reprAsJson = (v, jsonCol) => (jsonCol && (v === true || v === false)) || | ||
(typeof v === "object" && v !== null && !(v instanceof Date)); | ||
exports.reprAsJson = reprAsJson; | ||
@@ -24,3 +25,3 @@ /** | ||
*/ | ||
const mkVal = ([k, v]) => (0, exports.reprAsJson)(v) ? JSON.stringify(v) : v; | ||
const mkVal = ([k, v], jsonCol) => (0, exports.reprAsJson)(v, jsonCol) ? JSON.stringify(v) : v; | ||
exports.mkVal = mkVal; | ||
@@ -40,3 +41,3 @@ /** | ||
? `coalesce((select max(_version) from "${(0, internal_1.sqlsanitize)(tbl)}" where id=${+v.next_version_by_id}), 0)+1` | ||
: (0, exports.reprAsJson)(v) | ||
: (0, exports.reprAsJson)(v, opts.jsonCols?.includes(k)) | ||
? "json(?)" | ||
@@ -47,3 +48,5 @@ : "?") | ||
.filter(([k, v]) => !(v && v.next_version_by_id)) | ||
.map(exports.mkVal); | ||
.map(([k, v]) => { | ||
return (0, exports.mkVal)([k, v], opts.jsonCols?.includes(k)); | ||
}); | ||
const ignoreExisting = opts.ignoreExisting ? "or ignore" : ""; | ||
@@ -77,3 +80,3 @@ const replace = opts.replace ? "or replace" : ""; | ||
.filter(([k, v]) => !(v && v.next_version_by_id)) | ||
.map(exports.mkVal); | ||
.map(([k, v]) => (0, exports.mkVal)([k, v])); | ||
if (!fieldsWithRows[fnames]) | ||
@@ -80,0 +83,0 @@ fieldsWithRows[fnames] = { |
{ | ||
"name": "@saltcorn/db-common", | ||
"version": "0.9.6-beta.11", | ||
"version": "0.9.6-beta.12", | ||
"description": "Db common structures for Saltcorn, open-source no-code platform", | ||
@@ -5,0 +5,0 @@ "homepage": "https://saltcorn.com", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111420
1550