@teamkeel/functions-runtime 0.401.4 → 0.402.0
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/package.json +2 -2
- package/src/ModelAPI.test.js +8 -51
- package/src/QueryBuilder.js +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamkeel/functions-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.402.0",
|
|
4
4
|
"description": "Internal package used by @teamkeel/sdk",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"change-case": "^4.1.2",
|
|
32
32
|
"json-rpc-2.0": "^1.7.0",
|
|
33
33
|
"ksuid": "^3.0.0",
|
|
34
|
-
"kysely": "~0.
|
|
34
|
+
"kysely": "~0.27.5",
|
|
35
35
|
"pg": "^8.13.1",
|
|
36
36
|
"postgres-interval": "^4.0.2",
|
|
37
37
|
"traceparent": "^1.0.0",
|
package/src/ModelAPI.test.js
CHANGED
|
@@ -863,15 +863,10 @@ test("ModelAPI.findMany - relationships - duplicate joins handled", async () =>
|
|
|
863
863
|
name: "Jim",
|
|
864
864
|
},
|
|
865
865
|
})
|
|
866
|
-
.orWhere({
|
|
867
|
-
author: {
|
|
868
|
-
name: "Bob",
|
|
869
|
-
},
|
|
870
|
-
})
|
|
871
866
|
.findMany();
|
|
872
867
|
|
|
873
|
-
expect(posts.length).toEqual(
|
|
874
|
-
expect(posts.map((x) => x.id).sort()).toEqual([post1.id
|
|
868
|
+
expect(posts.length).toEqual(1);
|
|
869
|
+
expect(posts.map((x) => x.id).sort()).toEqual([post1.id].sort());
|
|
875
870
|
});
|
|
876
871
|
|
|
877
872
|
test("ModelAPI.update", async () => {
|
|
@@ -968,12 +963,9 @@ describe("QueryBuilder", () => {
|
|
|
968
963
|
});
|
|
969
964
|
|
|
970
965
|
const results = await postAPI
|
|
971
|
-
.where({ title: {
|
|
972
|
-
.orWhere({
|
|
973
|
-
title: { startsWith: "jon" },
|
|
974
|
-
})
|
|
966
|
+
.where({ title: { startsWith: "jon" } })
|
|
975
967
|
.findMany({
|
|
976
|
-
limit:
|
|
968
|
+
limit: 1,
|
|
977
969
|
offset: 1,
|
|
978
970
|
orderBy: {
|
|
979
971
|
title: "asc",
|
|
@@ -982,7 +974,7 @@ describe("QueryBuilder", () => {
|
|
|
982
974
|
|
|
983
975
|
// because we've offset by 1, adam should not appear in the results even though
|
|
984
976
|
// the query constraints match adam
|
|
985
|
-
expect(results).toEqual([
|
|
977
|
+
expect(results).toEqual([four]);
|
|
986
978
|
});
|
|
987
979
|
|
|
988
980
|
test("ModelAPI.findMany - complex query", async () => {
|
|
@@ -1006,7 +998,7 @@ describe("QueryBuilder", () => {
|
|
|
1006
998
|
});
|
|
1007
999
|
|
|
1008
1000
|
const rows = await personAPI
|
|
1009
|
-
// Will match
|
|
1001
|
+
// Will match Jane
|
|
1010
1002
|
.where({
|
|
1011
1003
|
name: {
|
|
1012
1004
|
startsWith: "J",
|
|
@@ -1016,16 +1008,9 @@ describe("QueryBuilder", () => {
|
|
|
1016
1008
|
lessThan: 10,
|
|
1017
1009
|
},
|
|
1018
1010
|
})
|
|
1019
|
-
// Will match Billy
|
|
1020
|
-
.orWhere({
|
|
1021
|
-
date: {
|
|
1022
|
-
after: new Date("2022-01-01"),
|
|
1023
|
-
before: new Date("2022-01-10"),
|
|
1024
|
-
},
|
|
1025
|
-
})
|
|
1026
1011
|
.findMany();
|
|
1027
|
-
expect(rows.length).toEqual(
|
|
1028
|
-
expect(rows.map((x) => x.id).sort()).toEqual([p.id
|
|
1012
|
+
expect(rows.length).toEqual(1);
|
|
1013
|
+
expect(rows.map((x) => x.id).sort()).toEqual([p.id].sort());
|
|
1029
1014
|
});
|
|
1030
1015
|
|
|
1031
1016
|
test("ModelAPI chained delete", async () => {
|
|
@@ -1065,34 +1050,6 @@ describe("QueryBuilder", () => {
|
|
|
1065
1050
|
expect(jake).toEqual(p);
|
|
1066
1051
|
});
|
|
1067
1052
|
|
|
1068
|
-
// test("Model API chained order by", async () => {
|
|
1069
|
-
// const p1 = await postAPI.create({
|
|
1070
|
-
// id: KSUID.randomSync().string,
|
|
1071
|
-
// title: "adam",
|
|
1072
|
-
// });
|
|
1073
|
-
// const p2 = await postAPI.create({
|
|
1074
|
-
// id: KSUID.randomSync().string,
|
|
1075
|
-
// title: "dave",
|
|
1076
|
-
// });
|
|
1077
|
-
// const p3 = await postAPI.create({
|
|
1078
|
-
// id: KSUID.randomSync().string,
|
|
1079
|
-
// title: "jon",
|
|
1080
|
-
// });
|
|
1081
|
-
// const p4 = await postAPI.create({
|
|
1082
|
-
// id: KSUID.randomSync().string,
|
|
1083
|
-
// title: "jon bretman",
|
|
1084
|
-
// });
|
|
1085
|
-
|
|
1086
|
-
// const query = postAPI
|
|
1087
|
-
// .where({ title: "adam" })
|
|
1088
|
-
// .orWhere({ title: "dave" })
|
|
1089
|
-
// .orderBy({ title: "desc" });
|
|
1090
|
-
|
|
1091
|
-
// const results = await query.findMany();
|
|
1092
|
-
|
|
1093
|
-
// expect(results[0].id).toEqual(p2);
|
|
1094
|
-
// });
|
|
1095
|
-
|
|
1096
1053
|
test("ModelAPI chained update", async () => {
|
|
1097
1054
|
const p1 = await postAPI.create({
|
|
1098
1055
|
id: KSUID.randomSync().string,
|
package/src/QueryBuilder.js
CHANGED
|
@@ -38,18 +38,6 @@ class QueryBuilder {
|
|
|
38
38
|
return new QueryBuilder(this._tableName, context, builder);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
orWhere(where) {
|
|
42
|
-
const context = this._context.clone();
|
|
43
|
-
|
|
44
|
-
let builder = applyJoins(context, this._db, where);
|
|
45
|
-
|
|
46
|
-
builder = builder.orWhere((qb) => {
|
|
47
|
-
return applyWhereConditions(context, qb, where);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return new QueryBuilder(this._tableName, context, builder);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
41
|
sql() {
|
|
54
42
|
return this._db.compile().sql;
|
|
55
43
|
}
|
|
@@ -144,33 +132,6 @@ class QueryBuilder {
|
|
|
144
132
|
});
|
|
145
133
|
}
|
|
146
134
|
|
|
147
|
-
// orderBy(conditions) {
|
|
148
|
-
// const context = this._context.clone();
|
|
149
|
-
|
|
150
|
-
// const builder = applyOrderBy(
|
|
151
|
-
// context,
|
|
152
|
-
// this._db,
|
|
153
|
-
// this._tableName,
|
|
154
|
-
// conditions
|
|
155
|
-
// );
|
|
156
|
-
|
|
157
|
-
// return new QueryBuilder(this._tableName, context, builder);
|
|
158
|
-
// }
|
|
159
|
-
|
|
160
|
-
// limit(limit) {
|
|
161
|
-
// const context = this._context.clone();
|
|
162
|
-
// const builder = applyLimit(context, this._db, limit);
|
|
163
|
-
|
|
164
|
-
// return new QueryBuilder(this._tableName, context, builder);
|
|
165
|
-
// }
|
|
166
|
-
|
|
167
|
-
// offset(offset) {
|
|
168
|
-
// const context = this._context.clone();
|
|
169
|
-
// const builder = applyOffset(context, builder, offset);
|
|
170
|
-
|
|
171
|
-
// return new QueryBuilder(this._tableName, context, builder);
|
|
172
|
-
// }
|
|
173
|
-
|
|
174
135
|
async findMany(params) {
|
|
175
136
|
const name = tracing.spanNameForModelAPI(this._modelName, "findMany");
|
|
176
137
|
const db = useDatabase();
|