Comparing version 2.10.2 to 2.10.3
{ | ||
"name": "leoric", | ||
"version": "2.10.2", | ||
"version": "2.10.3", | ||
"description": "JavaScript Object-relational mapping alchemy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,2 +44,8 @@ "use strict"; | ||
exports.DataType = DataType; | ||
function hasDataLength(dataLength) { | ||
if (typeof dataLength === 'number') { | ||
return dataLength > 0; | ||
} | ||
return !!dataLength; | ||
} | ||
/** | ||
@@ -62,3 +68,3 @@ * @example | ||
const chunks = []; | ||
chunks.push(dataLength && dataLength > 0 ? `${dataType}(${dataLength})` : dataType); | ||
chunks.push(hasDataLength(dataLength) ? `${dataType}(${dataLength})` : dataType); | ||
return chunks.join(' '); | ||
@@ -97,3 +103,3 @@ } | ||
const chunks = []; | ||
chunks.push(dataLength && dataLength > 0 ? `${dataType}(${dataLength})` : dataType); | ||
chunks.push(hasDataLength(dataLength) ? `${dataType}(${dataLength})` : dataType); | ||
return chunks.join(' '); | ||
@@ -145,3 +151,3 @@ } | ||
const chunks = []; | ||
chunks.push(dataLength && dataLength > 0 ? `${dataType}(${dataLength})` : dataType); | ||
chunks.push(hasDataLength(dataLength) ? `${dataType}(${dataLength})` : dataType); | ||
if (unsigned) | ||
@@ -148,0 +154,0 @@ chunks.push('UNSIGNED'); |
@@ -47,2 +47,9 @@ import Raw from './raw'; | ||
function hasDataLength(dataLength: string | number | undefined) { | ||
if (typeof dataLength === 'number') { | ||
return dataLength > 0; | ||
} | ||
return !!dataLength; | ||
} | ||
/** | ||
@@ -66,3 +73,3 @@ * @example | ||
const chunks: string[] = []; | ||
chunks.push(dataLength && dataLength > 0 ? `${dataType}(${dataLength})` : dataType); | ||
chunks.push(hasDataLength(dataLength) ? `${dataType}(${dataLength})` : dataType); | ||
return chunks.join(' '); | ||
@@ -105,3 +112,3 @@ } | ||
const chunks: string[] = []; | ||
chunks.push(dataLength && dataLength > 0 ? `${dataType}(${dataLength})` : dataType); | ||
chunks.push(hasDataLength(dataLength) ? `${dataType}(${dataLength})` : dataType); | ||
return chunks.join(' '); | ||
@@ -160,3 +167,3 @@ } | ||
const chunks: string[] = []; | ||
chunks.push(dataLength && dataLength > 0 ? `${dataType}(${dataLength})` : dataType); | ||
chunks.push(hasDataLength(dataLength) ? `${dataType}(${dataLength})` : dataType); | ||
if (unsigned) chunks.push('UNSIGNED'); | ||
@@ -163,0 +170,0 @@ if (zerofill) chunks.push('ZEROFILL'); |
@@ -120,3 +120,3 @@ 'use strict'; | ||
*/ | ||
constructor(index, type = INDEX_HINT_TYPE.use, scope = ''){ | ||
constructor(index, type = INDEX_HINT_TYPE.use, scope = '') { | ||
this.index = index; | ||
@@ -123,0 +123,0 @@ this.type = type; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
const { parseExprList, parseExpr, walkExpr } = require('./expr'); | ||
const { isPlainObject } = require('./utils'); | ||
const { isPlainObject, deepClone } = require('./utils'); | ||
const { IndexHint, INDEX_HINT_TYPE, Hint } = require('./hint'); | ||
@@ -393,3 +393,3 @@ const { parseObject } = require('./query_object'); | ||
groups: [], | ||
orders: JSON.parse(JSON.stringify(this.orders)), | ||
orders: deepClone(this.orders), | ||
havingConditions: [], | ||
@@ -774,3 +774,3 @@ joins: {}, | ||
if (column.value === value && column.type === 'alias') { | ||
condition.args[0] = JSON.parse(JSON.stringify(column.args[0])); | ||
condition.args[0] = deepClone(column.args[0]); | ||
break; | ||
@@ -777,0 +777,0 @@ } |
@@ -53,2 +53,6 @@ 'use strict'; | ||
const deepClone = typeof structuredClone === 'function' | ||
? structuredClone | ||
: (value) => JSON.parse(JSON.stringify(value)); | ||
module.exports = { | ||
@@ -61,2 +65,3 @@ isPlainObject, | ||
isBone, | ||
deepClone, | ||
}; |
Sorry, the diff of this file is not supported yet
362709
9972