@koralium/base-client 1.3.0-alpha9 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/parameterBuilder.js +1 -1
- package/lib/parameterBuilder.js.map +1 -1
- package/lib/queryResult.d.ts +2 -7
- package/lib/queryResult.js.map +1 -1
- package/package.json +2 -2
- package/src/parameterBuilder.ts +1 -1
- package/src/queryResult.ts +2 -8
- package/test-report.xml +14 -13
- package/tests/queryBuilder.test.ts +21 -1
package/lib/parameterBuilder.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parameterBuilder.js","sourceRoot":"","sources":["../src/parameterBuilder.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,MAAa,gBAAgB;IAA7B;QACE,uBAAkB,GAA6B,EAAE,CAAA;QACjD,YAAO,GAAW,CAAC,CAAC;IAoBtB,CAAC;IAlBC,gBAAgB,CAAC,KAAsB;QACnC,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE;YAC9C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;SACzC;aACI;YACD,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC;YAC9C,OAAO,YAAY,CAAC;SACvB;IACL,CAAC;IAED,aAAa;QACX,MAAM,MAAM,GAA6B,EAAE,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE;YAChE,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;
|
1
|
+
{"version":3,"file":"parameterBuilder.js","sourceRoot":"","sources":["../src/parameterBuilder.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,MAAa,gBAAgB;IAA7B;QACE,uBAAkB,GAA6B,EAAE,CAAA;QACjD,YAAO,GAAW,CAAC,CAAC;IAoBtB,CAAC;IAlBC,gBAAgB,CAAC,KAAsB;QACnC,IAAI,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,KAAK,SAAS,EAAE;YAC9C,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;SACzC;aACI;YACD,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC;YAC9C,OAAO,YAAY,CAAC;SACvB;IACL,CAAC;IAED,aAAa;QACX,MAAM,MAAM,GAA6B,EAAE,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE;YAChE,MAAM,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;SACzC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAtBD,4CAsBC"}
|
package/lib/queryResult.d.ts
CHANGED
@@ -2,15 +2,10 @@ export declare class Metadata {
|
|
2
2
|
customMetadata: {};
|
3
3
|
constructor(customMetadata: {});
|
4
4
|
}
|
5
|
-
export interface ResultArray<T> extends Iterable<T> {
|
6
|
-
length: number;
|
7
|
-
get(index: number): T;
|
8
|
-
toArray: () => Array<T>;
|
9
|
-
}
|
10
5
|
export declare class QueryResult<T extends {
|
11
6
|
[key: string]: any;
|
12
7
|
} = any> {
|
13
|
-
rows:
|
8
|
+
rows: Array<T>;
|
14
9
|
metadata: Metadata;
|
15
|
-
constructor(rows:
|
10
|
+
constructor(rows: Array<T>, metadata: Metadata);
|
16
11
|
}
|
package/lib/queryResult.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"queryResult.js","sourceRoot":"","sources":["../src/queryResult.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,MAAa,QAAQ;IAGnB,YAAY,cAAkB;QAC5B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AAND,4BAMC;
|
1
|
+
{"version":3,"file":"queryResult.js","sourceRoot":"","sources":["../src/queryResult.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,MAAa,QAAQ;IAGnB,YAAY,cAAkB;QAC5B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AAND,4BAMC;AAED,MAAa,WAAW;IAItB,YAAY,IAAc,EAAE,QAAkB;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AARD,kCAQC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@koralium/base-client",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.1",
|
4
4
|
"main": "./lib/index.js",
|
5
5
|
"license": "MIT",
|
6
6
|
"scripts": {
|
@@ -28,5 +28,5 @@
|
|
28
28
|
"ts-node": "^8.10.2",
|
29
29
|
"typescript": "^3.2.2"
|
30
30
|
},
|
31
|
-
"gitHead": "
|
31
|
+
"gitHead": "865598af01038cca8d14da8e4ba0a54fab170ff2"
|
32
32
|
}
|
package/src/parameterBuilder.ts
CHANGED
@@ -29,7 +29,7 @@ export class ParameterBuilder {
|
|
29
29
|
getParameters(): {} {
|
30
30
|
const output: {[key: string]: string;} = {};
|
31
31
|
for (let [key, value] of Object.entries(this.valuesToParameters)) {
|
32
|
-
output[value] = key;
|
32
|
+
output[value] = encodeURIComponent(key);
|
33
33
|
}
|
34
34
|
return output;
|
35
35
|
}
|
package/src/queryResult.ts
CHANGED
@@ -19,17 +19,11 @@ export class Metadata {
|
|
19
19
|
}
|
20
20
|
}
|
21
21
|
|
22
|
-
export interface ResultArray<T> extends Iterable<T> {
|
23
|
-
length: number
|
24
|
-
get(index: number): T;
|
25
|
-
toArray: () => Array<T>
|
26
|
-
}
|
27
|
-
|
28
22
|
export class QueryResult<T extends { [key: string]: any; } = any> {
|
29
|
-
rows:
|
23
|
+
rows: Array<T>;
|
30
24
|
metadata: Metadata;
|
31
25
|
|
32
|
-
constructor(rows:
|
26
|
+
constructor(rows: Array<T>, metadata: Metadata) {
|
33
27
|
this.rows = rows;
|
34
28
|
this.metadata = metadata;
|
35
29
|
}
|
package/test-report.xml
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<testExecutions version="1">
|
3
3
|
<file path="C:\Users\seosal\source\repos\Koralium\new\Koralium\typescript-client\base-client\tests\queryBuilder.test.ts">
|
4
|
-
<testCase name="count with filter" duration="
|
5
|
-
<testCase name="Select same column" duration="
|
6
|
-
<testCase name="Select with limit and offset" duration="
|
7
|
-
<testCase name="Select multiple columns, filter, limit, offset" duration="
|
8
|
-
<testCase name="Object mapper" duration="
|
4
|
+
<testCase name="count with filter" duration="8"/>
|
5
|
+
<testCase name="Select same column" duration="1"/>
|
6
|
+
<testCase name="Select with limit and offset" duration="1"/>
|
7
|
+
<testCase name="Select multiple columns, filter, limit, offset" duration="1"/>
|
8
|
+
<testCase name="Object mapper" duration="2"/>
|
9
9
|
<testCase name="Object mapper, missing mapping" duration="1"/>
|
10
|
-
<testCase name="Filter builder equals" duration="
|
10
|
+
<testCase name="Filter builder equals" duration="3"/>
|
11
11
|
<testCase name="test in predicate for numbers" duration="0"/>
|
12
|
-
<testCase name="test in predicate for strings" duration="
|
13
|
-
<testCase name="Order by with object ascending" duration="
|
12
|
+
<testCase name="test in predicate for strings" duration="0"/>
|
13
|
+
<testCase name="Order by with object ascending" duration="1"/>
|
14
14
|
<testCase name="Order by with object descending" duration="0"/>
|
15
15
|
<testCase name="Empty filter string" duration="1"/>
|
16
16
|
<testCase name="Empty filter object" duration="0"/>
|
17
|
-
<testCase name="Search filter all fields" duration="
|
18
|
-
<testCase name="Search filter two fields" duration="
|
19
|
-
<testCase name="Boolean filter" duration="
|
17
|
+
<testCase name="Search filter all fields" duration="1"/>
|
18
|
+
<testCase name="Search filter two fields" duration="1"/>
|
19
|
+
<testCase name="Boolean filter" duration="1"/>
|
20
20
|
<testCase name="IN filter with strings" duration="1"/>
|
21
|
-
<testCase name="IN filter with numbers" duration="
|
22
|
-
<testCase name="IN filter with booleans" duration="
|
21
|
+
<testCase name="IN filter with numbers" duration="2"/>
|
22
|
+
<testCase name="IN filter with booleans" duration="2"/>
|
23
|
+
<testCase name="filter with åäö" duration="1"/>
|
23
24
|
</file>
|
24
25
|
</testExecutions>
|
@@ -306,4 +306,24 @@ test("IN filter with booleans", () => {
|
|
306
306
|
.buildQuery();
|
307
307
|
|
308
308
|
expect(result).toEqual(expected);
|
309
|
-
});
|
309
|
+
});
|
310
|
+
|
311
|
+
test("filter with åäö", () => {
|
312
|
+
const expected = "SELECT count(*) FROM testtable WHERE (name IN (@P0))"
|
313
|
+
|
314
|
+
const queryBuilder = new QueryBuilder("testtable");
|
315
|
+
const result = queryBuilder
|
316
|
+
.addSelectElement("count(*)")
|
317
|
+
.addFilter({
|
318
|
+
name: {in: ["åäö"]}
|
319
|
+
})
|
320
|
+
.buildQuery();
|
321
|
+
|
322
|
+
const parametersResult = queryBuilder.getParameters();
|
323
|
+
const expectedParameters = {
|
324
|
+
P0: encodeURIComponent("åäö")
|
325
|
+
};
|
326
|
+
|
327
|
+
expect(result).toEqual(expected);
|
328
|
+
expect(parametersResult).toEqual(expectedParameters);
|
329
|
+
})
|