This commit is contained in:
陆柯 2022-07-23 13:04:16 +08:00
parent 852e82d5a9
commit 13c101a451

View File

@ -20,7 +20,6 @@ module.exports = {
let newObj = {} let newObj = {}
if (schemaColumns) { if (schemaColumns) {
for (let key in schemaColumns) { for (let key in schemaColumns) {
if (schemaColumns.hasOwnProperty(key) && !schemaColumns[key].hashExclusive && !excludeKeys.includes(key)) {
// JSON.stringify (包括本函数)会把 NaN 或 Infinity 输出为 null会把 undefined 忽略掉。 // JSON.stringify (包括本函数)会把 NaN 或 Infinity 输出为 null会把 undefined 忽略掉。
// 而在 typeorm sqlite 数据库中undefined 会自动存为 schemaColumns[key].default 或 null。从数据库读出时就会和事先JSON.stringify的结果不一致。 // 而在 typeorm sqlite 数据库中undefined 会自动存为 schemaColumns[key].default 或 null。从数据库读出时就会和事先JSON.stringify的结果不一致。
// 为了和 torm 数据库保持一致习惯对schemaColumns里的键值应当把 undefined 也设为 default 或 null。 // 为了和 torm 数据库保持一致习惯对schemaColumns里的键值应当把 undefined 也设为 default 或 null。
@ -31,10 +30,12 @@ module.exports = {
newObj[key] = obj[key] newObj[key] = obj[key]
} }
} }
}
} else { } else {
newObj = obj newObj = obj
} }
for (let exkey of excludeKeys) {
delete newObj[exkey]
}
/* 以下代码来自 https://github.com/substack/json-stable-stringify 可把嵌套的复杂值也按顺序输出,例如 { c: 8, b: [{z:6,y:5,x:4},7], a: 3 } */ /* 以下代码来自 https://github.com/substack/json-stable-stringify 可把嵌套的复杂值也按顺序输出,例如 { c: 8, b: [{z:6,y:5,x:4},7], a: 3 } */
if (typeof space === 'number') space = Array(space + 1).join(' ') if (typeof space === 'number') space = Array(space + 1).join(' ')