Comparing version 0.2.1 to 0.2.3
{ | ||
"name": "zol", | ||
"version": "0.2.1", | ||
"version": "0.2.3", | ||
"description": "Type safe composable SQL abstraction layer", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -79,3 +79,3 @@ import { Col, colUnwrap } from "./Column"; | ||
const names = tbl.tableCols.map<[ColName, string, (val: string) => any]>(x => [x.name, x.propName, x.parser]); | ||
const cs = <any>toTup(names); // tslint:disable-line:no-unnecessary-type-assertion | ||
const cs = <any>toTup(names, null); // tslint:disable-line:no-unnecessary-type-assertion | ||
const fs = rowValues.map(finalCols); | ||
@@ -94,3 +94,3 @@ const rs = finalCols(returning(cs)); | ||
const names = tbl.tableCols.map<[ColName, string, (val: string) => any]>(x => [x.name, x.propName, x.parser]); | ||
const cs = toTup<a>(names); | ||
const cs = toTup<a>(names, tbl.tableName); | ||
const updated: [ColName, SomeCol<SQL>][] = []; | ||
@@ -112,3 +112,3 @@ const fs2 = finalCols(upd(cs)); | ||
const names = tbl.tableCols.map<[ColName, string, (val: string) => any]>(x => [x.name, x.propName, x.parser]); | ||
const cs = toTup<a>(names); | ||
const cs = toTup<a>(names, null); | ||
const updated: [ColName, SomeCol<SQL>][] = []; | ||
@@ -126,3 +126,3 @@ const fs = finalCols(upd(cs)); | ||
} else { | ||
const cs = <any>toTup(names); // tslint:disable-line:no-unnecessary-type-assertion | ||
const cs = <any>toTup(names, null); // tslint:disable-line:no-unnecessary-type-assertion | ||
const rs = finalCols(returning(cs)); | ||
@@ -135,5 +135,5 @@ return compUpdate(tbl.tableName, predicate, updated, rs); | ||
const names = tbl.tableCols.map<[ColName, string, (val: string) => any]>(x => [x.name, x.propName, x.parser]); | ||
const cs = toTup<a>(names); | ||
const cs = toTup<a>(names, null); | ||
const predicate = colUnwrap(check(cs)); | ||
return compDelete(tbl.tableName, predicate); | ||
} |
import * as SqlType from "./SqlType"; | ||
import { ColName } from "./Types"; | ||
import { ColName, TableName } from "./Types"; | ||
@@ -43,2 +43,3 @@ export type SomeCol<sql> = SomeCol.Some<sql> | SomeCol.Named<sql>; | ||
readonly type: "ECol"; | ||
readonly correlation: TableName | null; | ||
readonly colName: ColName; | ||
@@ -45,0 +46,0 @@ readonly parser: (val: string) => any; |
@@ -122,3 +122,3 @@ import { Col } from "./Column"; | ||
const names = table.tableCols.map<[ColName, string, (val: string) => any]>(x => [x.name, x.propName, x.parser]); | ||
const cs = <any>toTup(names); // tslint:disable-line:no-unnecessary-type-assertion | ||
const cs = <any>toTup(names, null); // tslint:disable-line:no-unnecessary-type-assertion | ||
const rs = finalCols(returning(cs)); | ||
@@ -125,0 +125,0 @@ |
@@ -11,3 +11,3 @@ import { Col, colUnwrap, colWrap } from "./Column"; | ||
import { allCols, colNames, state2sql } from "./Transform"; | ||
import { ColName } from "./Types"; | ||
import { ColName, TableName } from "./Types"; | ||
@@ -25,2 +25,3 @@ function mkSome<sql, a>(val: Exp<sql, a>, parser: (val: string) => a): SomeCol<sql> { | ||
type: "ECol", | ||
correlation: null, | ||
colName: val, | ||
@@ -90,3 +91,3 @@ parser: parser | ||
State.put(st2), | ||
() => State.pure(toTup(someColNames2(rns))) | ||
() => State.pure(toTup(someColNames2(rns), null)) | ||
); | ||
@@ -158,2 +159,3 @@ } | ||
type: "ECol", | ||
correlation: null, | ||
colName: n, | ||
@@ -186,3 +188,3 @@ parser: () => { throw new Error("ECol parser"); } | ||
} | ||
return State.pure(toTup(ts)); | ||
return State.pure(toTup(ts, null)); | ||
} | ||
@@ -257,3 +259,3 @@ ); | ||
})), | ||
() => State.pure(toTup(someColNames2(cs))) | ||
() => State.pure(toTup(someColNames2(cs), null)) | ||
); | ||
@@ -551,3 +553,3 @@ } | ||
}); | ||
const on: Col<s, boolean> = check(toTup(nameds)); | ||
const on: Col<s, boolean> = check(toTup(nameds, null)); | ||
let outCols: SomeCol<SQL>[] = []; | ||
@@ -561,2 +563,3 @@ for (const c of cs) { | ||
type: "ECol", | ||
correlation: null, | ||
colName: c2.colName, | ||
@@ -581,3 +584,3 @@ parser: c2.parser | ||
}), | ||
() => State.pure(toTup(nameds)) | ||
() => State.pure(toTup(nameds, null)) | ||
); | ||
@@ -613,3 +616,3 @@ } | ||
export function toTup<a>(colNames: [ColName, string, (val: string) => any][]): a { | ||
export function toTup<a>(colNames: [ColName, string, (val: string) => any][], correlation: TableName | null): a { | ||
const results: any = {}; | ||
@@ -620,2 +623,3 @@ for (const c of colNames) { | ||
type: "ECol", | ||
correlation: correlation, | ||
colName: colName, | ||
@@ -622,0 +626,0 @@ parser: parser |
@@ -47,3 +47,3 @@ import { assertNever } from "../assertNever"; | ||
inserts => State.bind( | ||
cs2 === undefined ? State.pure(undefined) : State.mapM(ppUpdate, cs2), | ||
cs2 === undefined ? State.pure(undefined) : State.mapM(x => ppUpdate(x, tbl), cs2), | ||
updates => State.bind( | ||
@@ -116,3 +116,3 @@ p === undefined ? State.pure(undefined) : ppCol(p), | ||
const ppUpd: PP<string> = State.bind( | ||
State.mapM(ppUpdate, cs), | ||
State.mapM(x => ppUpdate(x, null), cs), | ||
updates => State.bind( | ||
@@ -152,3 +152,3 @@ ppCol(p), | ||
// left=false, right=true | ||
function ppUpdate([n, c]: [ColName, SomeCol<SQL>]): PP<[boolean, string]> { | ||
function ppUpdate([n, c]: [ColName, SomeCol<SQL>], correlation: TableName | null): PP<[boolean, string]> { | ||
const n2 = fromColName(n); | ||
@@ -162,3 +162,7 @@ if (c.exp === <any>defaultValue()) { | ||
const upd = n2 + " = " + c2; | ||
if (n2 === c2) { | ||
if (c.type === "Some" && | ||
c.exp.type === "ECol" && | ||
c.exp.correlation === correlation && | ||
c.exp.colName === n) { | ||
// Setting a column to its own value | ||
return State.pure<PPState, [boolean, string]>([false, upd]); | ||
@@ -204,3 +208,7 @@ } else { | ||
case "ECol": | ||
return State.pure(fromColName(c.colName)); | ||
if (c.correlation === null) { | ||
return State.pure(fromColName(c.colName)); | ||
} else { | ||
return State.pure(fromTableName(c.correlation) + "." + fromColName(c.colName)); | ||
} | ||
case "ELit": | ||
@@ -207,0 +215,0 @@ return ppLit(c.lit); |
@@ -183,2 +183,3 @@ import { assertNever } from "./assertNever"; | ||
type: "ECol", | ||
correlation: null, | ||
colName: s.colName, | ||
@@ -185,0 +186,0 @@ parser: s.parser |
@@ -28,3 +28,3 @@ import { Col } from "./Column"; | ||
const names = table.tableCols.map<[ColName, string, (val: string) => any]>(x => [x.name, x.propName, x.parser]); | ||
const cs = <any>toTup(names); // tslint:disable-line:no-unnecessary-type-assertion | ||
const cs = <any>toTup(names, null); // tslint:disable-line:no-unnecessary-type-assertion | ||
const rs = finalCols(returning(cs)); | ||
@@ -31,0 +31,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
6521824
11773