Skip to content

Commit 4a1532c

Browse files
cast variable extracted from val in case wrapper,
type defs updated for cast support, console.log removed
1 parent ef74c6e commit 4a1532c

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

defs/types.js

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
* @prop {boolean|WhereObject} check
127127
* @prop {*} trueValue
128128
* @prop {*} falseValue
129+
* @prop {CastingTypes} [cast]
129130
* @prop {string} [as]
130131
*/
131132

@@ -155,6 +156,7 @@
155156
* @typedef {Object} SwitchObject
156157
* @prop {Array<WhenThenCondition>} check
157158
* @prop {ValuesObject} else
159+
* @prop {CastingTypes} [cast]
158160
* @prop {string} [as]
159161
*/
160162

helpers/main.helper.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ const prepWhere = ({ alias, where = {}, parent = null, junction = 'and', values,
175175
sqlParts.push(prepWhere({ alias, where: val, parent: key, junction, values, encryption, ctx }))
176176
}
177177

178-
console.log('sql parts generated', sqlParts)
179178
return sqlParts.filter(Boolean).join(junctions[junction])
180179
}
181180

@@ -426,7 +425,7 @@ const prepIf = ({ alias, val, junction = 'and', values, encryption = undefined,
426425
@returns {{sql:string, values:Array}} 'sql' with placeholder string and 'values' array to be injected at execution
427426
*/
428427
const prepCase = ({ alias, val, junction = 'and', values, encryption = undefined, ctx = undefined }) => {
429-
const { check = [], else: defaultElse, as = null } = val
428+
const { check = [], else: defaultElse, cast = null, as = null } = val
430429
const conditionalPlaceholders = check.map(condition => {
431430
const { when, then } = condition
432431
const whenPlaceholder = handlePlaceholder({ alias, value: when, junction, values, encryption, ctx })

unsql.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -670,4 +670,5 @@ class SessionManager {
670670
}
671671
}
672672

673-
module.exports = { UnSQL, SessionManager }
673+
module.exports = { UnSQL, SessionManager }
674+
module.exports.default = UnSQL

0 commit comments

Comments
 (0)