rado 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/Formatter.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare abstract class Formatter implements Sanitizer {
|
|
|
16
16
|
constructor();
|
|
17
17
|
abstract escapeValue(value: any): string;
|
|
18
18
|
abstract escapeIdentifier(ident: string): string;
|
|
19
|
+
abstract formatParamValue(paramValue: any): any;
|
|
19
20
|
abstract formatSqlAccess(on: Statement, field: string): Statement;
|
|
20
21
|
abstract formatJsonAccess(on: Statement, field: string): Statement;
|
|
21
22
|
formatAccess(on: Statement, field: string, formatAsJson?: boolean): Statement;
|
package/dist/lib/Sanitizer.d.ts
CHANGED
package/dist/lib/Statement.js
CHANGED
|
@@ -148,7 +148,9 @@ var Statement = class {
|
|
|
148
148
|
sql += sanitizer.escapeValue(token.data);
|
|
149
149
|
} else {
|
|
150
150
|
sql += "?";
|
|
151
|
-
paramData.push(
|
|
151
|
+
paramData.push(
|
|
152
|
+
ParamData.Value(sanitizer.formatParamValue(token.data))
|
|
153
|
+
);
|
|
152
154
|
}
|
|
153
155
|
break;
|
|
154
156
|
case "Param" /* Param */:
|
|
@@ -174,9 +176,9 @@ var CompiledStatement = class {
|
|
|
174
176
|
params(input) {
|
|
175
177
|
return this.paramData.map((param2) => {
|
|
176
178
|
if (param2.type === ParamType.Named) {
|
|
177
|
-
if (input
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
if (input && param2.name in input)
|
|
180
|
+
return input[param2.name];
|
|
181
|
+
throw new TypeError(`Missing parameter ${param2.name}`);
|
|
180
182
|
}
|
|
181
183
|
return param2.value;
|
|
182
184
|
});
|
|
@@ -2,6 +2,7 @@ import { ExprData } from '../lib/Expr';
|
|
|
2
2
|
import { FormatContext, Formatter } from '../lib/Formatter';
|
|
3
3
|
import { Statement } from '../lib/Statement';
|
|
4
4
|
export declare class SqliteFormatter extends Formatter {
|
|
5
|
+
formatParamValue(paramValue: any): any;
|
|
5
6
|
escapeValue(value: any): string;
|
|
6
7
|
escapeIdentifier(input: string): string;
|
|
7
8
|
escapeString(input: string): string;
|
|
@@ -15,6 +15,17 @@ function escapeWithin(input, outer) {
|
|
|
15
15
|
return buf;
|
|
16
16
|
}
|
|
17
17
|
var SqliteFormatter = class extends Formatter {
|
|
18
|
+
formatParamValue(paramValue) {
|
|
19
|
+
if (paramValue === null || paramValue === void 0)
|
|
20
|
+
return null;
|
|
21
|
+
if (typeof paramValue === "boolean")
|
|
22
|
+
return paramValue ? 1 : 0;
|
|
23
|
+
if (typeof paramValue === "number")
|
|
24
|
+
return paramValue;
|
|
25
|
+
if (typeof paramValue === "string")
|
|
26
|
+
return paramValue;
|
|
27
|
+
return JSON.stringify(paramValue);
|
|
28
|
+
}
|
|
18
29
|
escapeValue(value) {
|
|
19
30
|
if (value === null || value === void 0)
|
|
20
31
|
return "null";
|