Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "zol", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Type safe composable SQL abstraction layer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -34,2 +34,6 @@ import { Exp } from "./Exp"; | ||
function nullParser(val: string): never { | ||
throw new Error(`Tried to parse a nullCol. This is likely a bug in zol, please report. Column value: "${val}"`); | ||
} | ||
export function nullCol<s>(): Col<s, null> { | ||
@@ -41,3 +45,3 @@ return colWrap({ | ||
}, | ||
parser: val => val | ||
parser: nullParser | ||
}); | ||
@@ -85,2 +89,14 @@ } | ||
export function ifThenElse<s, a>(if_: Col<s, boolean>, then: Col<s, a>, else_: Col<s, a>): Col<s, a> { | ||
// the "then" and "else_" columns are of the same type, so they | ||
// (supposedly) have the same parser, so we can arbitrarily pick | ||
// either one. | ||
// | ||
// However: we must watch out if "then" or "else_" was set to "nullCol()", | ||
// and in that case choose the other one's parser. | ||
// | ||
// (If both "then" and "else_" were set to "nullCol()" then the | ||
// the column will always have a NULL value and the parser we set | ||
// here wlil never be called) | ||
const parser = (<any>then).parser !== nullParser ? (<any>then).parser : (<any>else_).parser; | ||
return colWrap({ | ||
@@ -91,7 +107,3 @@ type: "EIfThenElse", | ||
expElse: colUnwrap(else_), | ||
// the "then" and "else_" columns are of the same type, so they | ||
// (supposedly) have the same parser, so we can arbitrarily pick | ||
// either one: | ||
parser: (<any>colUnwrap(then)).parser | ||
parser: parser | ||
}); | ||
@@ -98,0 +110,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
6516769
11729