@budibase/server 2.22.15 → 2.22.16
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/builder/assets/{index-d3456412.js → index-4c998325.js} +492 -492
- package/builder/index.html +1 -1
- package/client/budibase-client.js +2 -2
- package/dist/yarn.lock +24 -36
- package/package.json +9 -9
- package/scripts/test.sh +2 -2
- package/src/api/routes/public/tests/metrics.spec.js +0 -2
- package/src/api/routes/tests/appImport.spec.ts +0 -1
- package/src/api/routes/tests/automation.spec.ts +0 -2
- package/src/api/routes/tests/queries/generic-sql.spec.ts +34 -59
- package/src/api/routes/tests/queries/mongodb.spec.ts +17 -12
- package/src/api/routes/tests/row.spec.ts +18 -21
- package/src/api/routes/tests/user.spec.ts +0 -2
- package/src/api/routes/tests/viewV2.spec.ts +13 -18
- package/src/integration-test/mysql.spec.ts +61 -72
- package/src/integration-test/postgres.spec.ts +65 -61
- package/src/integrations/tests/utils/index.ts +78 -13
- package/src/integrations/tests/utils/mariadb.ts +31 -28
- package/src/integrations/tests/utils/mongodb.ts +25 -29
- package/src/integrations/tests/utils/mssql.ts +51 -36
- package/src/integrations/tests/utils/mysql.ts +36 -21
- package/src/integrations/tests/utils/postgres.ts +43 -26
- package/src/migrations/tests/index.spec.ts +0 -2
- package/src/sdk/app/rows/search/tests/external.spec.ts +0 -2
- package/src/tests/jestSetup.ts +2 -8
- package/src/tests/utilities/api/base.ts +41 -11
package/dist/yarn.lock
CHANGED
|
@@ -5875,6 +5875,13 @@
|
|
|
5875
5875
|
"@types/pouchdb-node" "*"
|
|
5876
5876
|
"@types/pouchdb-replication" "*"
|
|
5877
5877
|
|
|
5878
|
+
"@types/proper-lockfile@^4.1.4":
|
|
5879
|
+
version "4.1.4"
|
|
5880
|
+
resolved "https://registry.yarnpkg.com/@types/proper-lockfile/-/proper-lockfile-4.1.4.tgz#cd9fab92bdb04730c1ada542c356f03620f84008"
|
|
5881
|
+
integrity sha512-uo2ABllncSqg9F1D4nugVl9v93RmjxF6LJzQLMLDdPaXCUIDPeOJ21Gbqi43xNKzBi/WQ0Q0dICqufzQbMjipQ==
|
|
5882
|
+
dependencies:
|
|
5883
|
+
"@types/retry" "*"
|
|
5884
|
+
|
|
5878
5885
|
"@types/qs@*":
|
|
5879
5886
|
version "6.9.7"
|
|
5880
5887
|
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb"
|
|
@@ -5937,6 +5944,11 @@
|
|
|
5937
5944
|
dependencies:
|
|
5938
5945
|
"@types/node" "*"
|
|
5939
5946
|
|
|
5947
|
+
"@types/retry@*":
|
|
5948
|
+
version "0.12.5"
|
|
5949
|
+
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.5.tgz#f090ff4bd8d2e5b940ff270ab39fd5ca1834a07e"
|
|
5950
|
+
integrity sha512-3xSjTp3v03X/lSQLkczaN9UIEwJMoMCA1+Nb5HfbJEQWogdeQIyVtTvxPXDQjZ5zws8rFQfVfRdz03ARihPJgw==
|
|
5951
|
+
|
|
5940
5952
|
"@types/rimraf@^3.0.2":
|
|
5941
5953
|
version "3.0.2"
|
|
5942
5954
|
resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-3.0.2.tgz#a63d175b331748e5220ad48c901d7bbf1f44eef8"
|
|
@@ -11052,7 +11064,7 @@ fetch-cookie@0.11.0:
|
|
|
11052
11064
|
dependencies:
|
|
11053
11065
|
tough-cookie "^2.3.3 || ^3.0.1 || ^4.0.0"
|
|
11054
11066
|
|
|
11055
|
-
fflate@^0.4.
|
|
11067
|
+
fflate@^0.4.8:
|
|
11056
11068
|
version "0.4.8"
|
|
11057
11069
|
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae"
|
|
11058
11070
|
integrity sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==
|
|
@@ -17990,6 +18002,14 @@ postgres-interval@^1.1.0:
|
|
|
17990
18002
|
dependencies:
|
|
17991
18003
|
xtend "^4.0.0"
|
|
17992
18004
|
|
|
18005
|
+
posthog-js@^1.116.6:
|
|
18006
|
+
version "1.116.6"
|
|
18007
|
+
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.116.6.tgz#9a5c9f49230a76642f4c44d93b96710f886c2880"
|
|
18008
|
+
integrity sha512-rvt8HxzJD4c2B/xsUa4jle8ApdqljeBI2Qqjp4XJMohQf18DXRyM6b96H5/UMs8jxYuZG14Er0h/kEIWeU6Fmw==
|
|
18009
|
+
dependencies:
|
|
18010
|
+
fflate "^0.4.8"
|
|
18011
|
+
preact "^10.19.3"
|
|
18012
|
+
|
|
17993
18013
|
posthog-js@^1.13.4:
|
|
17994
18014
|
version "1.103.1"
|
|
17995
18015
|
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.103.1.tgz#f846c413c28aca204dc1527f49d39f651348f3c4"
|
|
@@ -17998,13 +18018,6 @@ posthog-js@^1.13.4:
|
|
|
17998
18018
|
fflate "^0.4.8"
|
|
17999
18019
|
preact "^10.19.3"
|
|
18000
18020
|
|
|
18001
|
-
posthog-js@^1.36.0:
|
|
18002
|
-
version "1.96.1"
|
|
18003
|
-
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.96.1.tgz#4f9719a24e4e14037b0e72d430194d7cdb576447"
|
|
18004
|
-
integrity sha512-kv1vQqYMt2BV3YHS+wxsbGuP+tz+M3y1AzNhz8TfkpY1HT8W/ONT0i0eQpeRr9Y+d4x/fZ6M4cXG5GMvi9lRCA==
|
|
18005
|
-
dependencies:
|
|
18006
|
-
fflate "^0.4.1"
|
|
18007
|
-
|
|
18008
18021
|
posthog-node@1.3.0:
|
|
18009
18022
|
version "1.3.0"
|
|
18010
18023
|
resolved "https://registry.yarnpkg.com/posthog-node/-/posthog-node-1.3.0.tgz#804ed2f213a2f05253f798bf9569d55a9cad94f7"
|
|
@@ -20406,16 +20419,7 @@ string-similarity@^4.0.4:
|
|
|
20406
20419
|
resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b"
|
|
20407
20420
|
integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==
|
|
20408
20421
|
|
|
20409
|
-
"string-width-cjs@npm:string-width@^4.2.0":
|
|
20410
|
-
version "4.2.3"
|
|
20411
|
-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
|
20412
|
-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
|
20413
|
-
dependencies:
|
|
20414
|
-
emoji-regex "^8.0.0"
|
|
20415
|
-
is-fullwidth-code-point "^3.0.0"
|
|
20416
|
-
strip-ansi "^6.0.1"
|
|
20417
|
-
|
|
20418
|
-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
|
|
20422
|
+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
|
|
20419
20423
|
version "4.2.3"
|
|
20420
20424
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
|
20421
20425
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
|
@@ -20505,7 +20509,7 @@ stringify-object@^3.2.1:
|
|
|
20505
20509
|
is-obj "^1.0.1"
|
|
20506
20510
|
is-regexp "^1.0.0"
|
|
20507
20511
|
|
|
20508
|
-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
|
20512
|
+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
|
20509
20513
|
version "6.0.1"
|
|
20510
20514
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
|
20511
20515
|
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
|
@@ -20519,13 +20523,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
|
|
|
20519
20523
|
dependencies:
|
|
20520
20524
|
ansi-regex "^4.1.0"
|
|
20521
20525
|
|
|
20522
|
-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
|
20523
|
-
version "6.0.1"
|
|
20524
|
-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
|
20525
|
-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
|
20526
|
-
dependencies:
|
|
20527
|
-
ansi-regex "^5.0.1"
|
|
20528
|
-
|
|
20529
20526
|
strip-ansi@^7.0.1:
|
|
20530
20527
|
version "7.0.1"
|
|
20531
20528
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2"
|
|
@@ -22429,7 +22426,7 @@ worker-farm@1.7.0:
|
|
|
22429
22426
|
dependencies:
|
|
22430
22427
|
errno "~0.1.7"
|
|
22431
22428
|
|
|
22432
|
-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
|
|
22429
|
+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
|
|
22433
22430
|
version "7.0.0"
|
|
22434
22431
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
|
22435
22432
|
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
|
@@ -22447,15 +22444,6 @@ wrap-ansi@^5.1.0:
|
|
|
22447
22444
|
string-width "^3.0.0"
|
|
22448
22445
|
strip-ansi "^5.0.0"
|
|
22449
22446
|
|
|
22450
|
-
wrap-ansi@^7.0.0:
|
|
22451
|
-
version "7.0.0"
|
|
22452
|
-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
|
22453
|
-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
|
22454
|
-
dependencies:
|
|
22455
|
-
ansi-styles "^4.0.0"
|
|
22456
|
-
string-width "^4.1.0"
|
|
22457
|
-
strip-ansi "^6.0.0"
|
|
22458
|
-
|
|
22459
22447
|
wrap-ansi@^8.1.0:
|
|
22460
22448
|
version "8.1.0"
|
|
22461
22449
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.22.
|
|
4
|
+
"version": "2.22.16",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"license": "GPL-3.0",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
51
|
-
"@budibase/backend-core": "2.22.
|
|
52
|
-
"@budibase/client": "2.22.
|
|
53
|
-
"@budibase/frontend-core": "2.22.
|
|
54
|
-
"@budibase/pro": "2.22.
|
|
55
|
-
"@budibase/shared-core": "2.22.
|
|
56
|
-
"@budibase/string-templates": "2.22.
|
|
57
|
-
"@budibase/types": "2.22.
|
|
51
|
+
"@budibase/backend-core": "2.22.16",
|
|
52
|
+
"@budibase/client": "2.22.16",
|
|
53
|
+
"@budibase/frontend-core": "2.22.16",
|
|
54
|
+
"@budibase/pro": "2.22.16",
|
|
55
|
+
"@budibase/shared-core": "2.22.16",
|
|
56
|
+
"@budibase/string-templates": "2.22.16",
|
|
57
|
+
"@budibase/types": "2.22.16",
|
|
58
58
|
"@bull-board/api": "5.10.2",
|
|
59
59
|
"@bull-board/koa": "5.10.2",
|
|
60
60
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -196,5 +196,5 @@
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
|
-
"gitHead": "
|
|
199
|
+
"gitHead": "4a14e2ae9fdbc95da043dae51af41e53a7cd8bb8"
|
|
200
200
|
}
|
package/scripts/test.sh
CHANGED
|
@@ -4,8 +4,8 @@ set -e
|
|
|
4
4
|
if [[ -n $CI ]]
|
|
5
5
|
then
|
|
6
6
|
export NODE_OPTIONS="--max-old-space-size=4096 --no-node-snapshot $NODE_OPTIONS"
|
|
7
|
-
echo "jest --coverage --maxWorkers=
|
|
8
|
-
jest --coverage --maxWorkers=
|
|
7
|
+
echo "jest --coverage --maxWorkers=4 --forceExit --workerIdleMemoryLimit=2000MB --bail $@"
|
|
8
|
+
jest --coverage --maxWorkers=4 --forceExit --workerIdleMemoryLimit=2000MB --bail $@
|
|
9
9
|
else
|
|
10
10
|
# --maxWorkers performs better in development
|
|
11
11
|
export NODE_OPTIONS="--no-node-snapshot $NODE_OPTIONS"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Datasource, Query, SourceName } from "@budibase/types"
|
|
2
2
|
import * as setup from "../utilities"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
DatabaseName,
|
|
5
|
+
getDatasource,
|
|
6
|
+
rawQuery,
|
|
7
|
+
} from "../../../../integrations/tests/utils"
|
|
7
8
|
|
|
8
9
|
jest.unmock("pg")
|
|
9
10
|
|
|
@@ -34,13 +35,16 @@ const createTableSQL: Record<string, string> = {
|
|
|
34
35
|
const insertSQL = `INSERT INTO test_table (name) VALUES ('one'), ('two'), ('three'), ('four'), ('five')`
|
|
35
36
|
const dropTableSQL = `DROP TABLE test_table;`
|
|
36
37
|
|
|
37
|
-
describe.each(
|
|
38
|
-
[
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
describe.each(
|
|
39
|
+
[
|
|
40
|
+
DatabaseName.POSTGRES,
|
|
41
|
+
DatabaseName.MYSQL,
|
|
42
|
+
DatabaseName.SQL_SERVER,
|
|
43
|
+
DatabaseName.MARIADB,
|
|
44
|
+
].map(name => [name, getDatasource(name)])
|
|
45
|
+
)("queries (%s)", (dbName, dsProvider) => {
|
|
43
46
|
const config = setup.getConfig()
|
|
47
|
+
let rawDatasource: Datasource
|
|
44
48
|
let datasource: Datasource
|
|
45
49
|
|
|
46
50
|
async function createQuery(query: Partial<Query>): Promise<Query> {
|
|
@@ -57,62 +61,22 @@ describe.each([
|
|
|
57
61
|
return await config.api.query.save({ ...defaultQuery, ...query })
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
async function rawQuery(sql: string): Promise<any> {
|
|
61
|
-
// We re-fetch the datasource here because the one returned by
|
|
62
|
-
// config.api.datasource.create has the password field blanked out, and we
|
|
63
|
-
// need the password to connect to the database.
|
|
64
|
-
const ds = await dsProvider.datasource()
|
|
65
|
-
switch (ds.source) {
|
|
66
|
-
case SourceName.POSTGRES: {
|
|
67
|
-
const client = new pg.Client(ds.config!)
|
|
68
|
-
await client.connect()
|
|
69
|
-
try {
|
|
70
|
-
const { rows } = await client.query(sql)
|
|
71
|
-
return rows
|
|
72
|
-
} finally {
|
|
73
|
-
await client.end()
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
case SourceName.MYSQL: {
|
|
77
|
-
const con = await mysql.createConnection(ds.config!)
|
|
78
|
-
try {
|
|
79
|
-
const [rows] = await con.query(sql)
|
|
80
|
-
return rows
|
|
81
|
-
} finally {
|
|
82
|
-
con.end()
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
case SourceName.SQL_SERVER: {
|
|
86
|
-
const pool = new mssql.ConnectionPool(ds.config! as mssql.config)
|
|
87
|
-
const client = await pool.connect()
|
|
88
|
-
try {
|
|
89
|
-
const { recordset } = await client.query(sql)
|
|
90
|
-
return recordset
|
|
91
|
-
} finally {
|
|
92
|
-
await pool.close()
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
64
|
beforeAll(async () => {
|
|
99
65
|
await config.init()
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
66
|
+
rawDatasource = await dsProvider
|
|
67
|
+
datasource = await config.api.datasource.create(rawDatasource)
|
|
103
68
|
})
|
|
104
69
|
|
|
105
70
|
beforeEach(async () => {
|
|
106
|
-
await rawQuery(createTableSQL[datasource.source])
|
|
107
|
-
await rawQuery(insertSQL)
|
|
71
|
+
await rawQuery(rawDatasource, createTableSQL[datasource.source])
|
|
72
|
+
await rawQuery(rawDatasource, insertSQL)
|
|
108
73
|
})
|
|
109
74
|
|
|
110
75
|
afterEach(async () => {
|
|
111
|
-
await rawQuery(dropTableSQL)
|
|
76
|
+
await rawQuery(rawDatasource, dropTableSQL)
|
|
112
77
|
})
|
|
113
78
|
|
|
114
79
|
afterAll(async () => {
|
|
115
|
-
await dsProvider.stop()
|
|
116
80
|
setup.afterAll()
|
|
117
81
|
})
|
|
118
82
|
|
|
@@ -143,7 +107,10 @@ describe.each([
|
|
|
143
107
|
},
|
|
144
108
|
])
|
|
145
109
|
|
|
146
|
-
const rows = await rawQuery(
|
|
110
|
+
const rows = await rawQuery(
|
|
111
|
+
rawDatasource,
|
|
112
|
+
"SELECT * FROM test_table WHERE name = 'baz'"
|
|
113
|
+
)
|
|
147
114
|
expect(rows).toHaveLength(1)
|
|
148
115
|
})
|
|
149
116
|
|
|
@@ -171,6 +138,7 @@ describe.each([
|
|
|
171
138
|
expect(result.data).toEqual([{ created: true }])
|
|
172
139
|
|
|
173
140
|
const rows = await rawQuery(
|
|
141
|
+
rawDatasource,
|
|
174
142
|
`SELECT * FROM test_table WHERE birthday = '${date.toISOString()}'`
|
|
175
143
|
)
|
|
176
144
|
expect(rows).toHaveLength(1)
|
|
@@ -202,6 +170,7 @@ describe.each([
|
|
|
202
170
|
expect(result.data).toEqual([{ created: true }])
|
|
203
171
|
|
|
204
172
|
const rows = await rawQuery(
|
|
173
|
+
rawDatasource,
|
|
205
174
|
`SELECT * FROM test_table WHERE name = '${notDateStr}'`
|
|
206
175
|
)
|
|
207
176
|
expect(rows).toHaveLength(1)
|
|
@@ -338,7 +307,10 @@ describe.each([
|
|
|
338
307
|
},
|
|
339
308
|
])
|
|
340
309
|
|
|
341
|
-
const rows = await rawQuery(
|
|
310
|
+
const rows = await rawQuery(
|
|
311
|
+
rawDatasource,
|
|
312
|
+
"SELECT * FROM test_table WHERE id = 1"
|
|
313
|
+
)
|
|
342
314
|
expect(rows).toEqual([
|
|
343
315
|
{ id: 1, name: "foo", birthday: null, number: null },
|
|
344
316
|
])
|
|
@@ -406,7 +378,10 @@ describe.each([
|
|
|
406
378
|
},
|
|
407
379
|
])
|
|
408
380
|
|
|
409
|
-
const rows = await rawQuery(
|
|
381
|
+
const rows = await rawQuery(
|
|
382
|
+
rawDatasource,
|
|
383
|
+
"SELECT * FROM test_table WHERE id = 1"
|
|
384
|
+
)
|
|
410
385
|
expect(rows).toHaveLength(0)
|
|
411
386
|
})
|
|
412
387
|
})
|
|
@@ -443,7 +418,7 @@ describe.each([
|
|
|
443
418
|
} catch (err: any) {
|
|
444
419
|
error = err.message
|
|
445
420
|
}
|
|
446
|
-
if (dbName ===
|
|
421
|
+
if (dbName === DatabaseName.SQL_SERVER) {
|
|
447
422
|
expect(error).toBeUndefined()
|
|
448
423
|
} else {
|
|
449
424
|
expect(error).toBeDefined()
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Datasource, Query } from "@budibase/types"
|
|
2
2
|
import * as setup from "../utilities"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
DatabaseName,
|
|
5
|
+
getDatasource,
|
|
6
|
+
} from "../../../../integrations/tests/utils"
|
|
7
|
+
import { MongoClient, type Collection, BSON, Db } from "mongodb"
|
|
8
|
+
import { generator } from "@budibase/backend-core/tests"
|
|
7
9
|
|
|
8
10
|
const expectValidId = expect.stringMatching(/^\w{24}$/)
|
|
9
11
|
const expectValidBsonObjectId = expect.any(BSON.ObjectId)
|
|
10
12
|
|
|
11
13
|
describe("/queries", () => {
|
|
14
|
+
let collection: string
|
|
12
15
|
let config = setup.getConfig()
|
|
13
16
|
let datasource: Datasource
|
|
14
17
|
|
|
@@ -37,8 +40,7 @@ describe("/queries", () => {
|
|
|
37
40
|
async function withClient<T>(
|
|
38
41
|
callback: (client: MongoClient) => Promise<T>
|
|
39
42
|
): Promise<T> {
|
|
40
|
-
const
|
|
41
|
-
const client = new MongoClient(ds.config!.connectionString)
|
|
43
|
+
const client = new MongoClient(datasource.config!.connectionString)
|
|
42
44
|
await client.connect()
|
|
43
45
|
try {
|
|
44
46
|
return await callback(client)
|
|
@@ -47,30 +49,33 @@ describe("/queries", () => {
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
async function withDb<T>(callback: (db: Db) => Promise<T>): Promise<T> {
|
|
53
|
+
return await withClient(async client => {
|
|
54
|
+
return await callback(client.db(datasource.config!.db))
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
async function withCollection<T>(
|
|
51
59
|
callback: (collection: Collection) => Promise<T>
|
|
52
60
|
): Promise<T> {
|
|
53
|
-
return await
|
|
54
|
-
const db = client.db(
|
|
55
|
-
(await databaseTestProviders.mongodb.datasource()).config!.db
|
|
56
|
-
)
|
|
61
|
+
return await withDb(async db => {
|
|
57
62
|
return await callback(db.collection(collection))
|
|
58
63
|
})
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
afterAll(async () => {
|
|
62
|
-
await databaseTestProviders.mongodb.stop()
|
|
63
67
|
setup.afterAll()
|
|
64
68
|
})
|
|
65
69
|
|
|
66
70
|
beforeAll(async () => {
|
|
67
71
|
await config.init()
|
|
68
72
|
datasource = await config.api.datasource.create(
|
|
69
|
-
await
|
|
73
|
+
await getDatasource(DatabaseName.MONGODB)
|
|
70
74
|
)
|
|
71
75
|
})
|
|
72
76
|
|
|
73
77
|
beforeEach(async () => {
|
|
78
|
+
collection = generator.guid()
|
|
74
79
|
await withCollection(async collection => {
|
|
75
80
|
await collection.insertMany([
|
|
76
81
|
{ name: "one" },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
|
2
2
|
|
|
3
3
|
import tk from "timekeeper"
|
|
4
4
|
import { outputProcessing } from "../../../utilities/rowProcessor"
|
|
@@ -34,10 +34,10 @@ jest.unmock("pg")
|
|
|
34
34
|
|
|
35
35
|
describe.each([
|
|
36
36
|
["internal", undefined],
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
37
|
+
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
|
38
|
+
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
|
39
|
+
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
|
40
|
+
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
|
41
41
|
])("/rows (%s)", (__, dsProvider) => {
|
|
42
42
|
const isInternal = dsProvider === undefined
|
|
43
43
|
const config = setup.getConfig()
|
|
@@ -49,23 +49,23 @@ describe.each([
|
|
|
49
49
|
await config.init()
|
|
50
50
|
if (dsProvider) {
|
|
51
51
|
datasource = await config.createDatasource({
|
|
52
|
-
datasource: await dsProvider
|
|
52
|
+
datasource: await dsProvider,
|
|
53
53
|
})
|
|
54
54
|
}
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
afterAll(async () => {
|
|
58
|
-
if (dsProvider) {
|
|
59
|
-
await dsProvider.stop()
|
|
60
|
-
}
|
|
61
58
|
setup.afterAll()
|
|
62
59
|
})
|
|
63
60
|
|
|
64
61
|
function saveTableRequest(
|
|
65
|
-
|
|
62
|
+
// We omit the name field here because it's generated in the function with a
|
|
63
|
+
// high likelihood to be unique. Tests should not have any reason to control
|
|
64
|
+
// the table name they're writing to.
|
|
65
|
+
...overrides: Partial<Omit<SaveTableRequest, "name">>[]
|
|
66
66
|
): SaveTableRequest {
|
|
67
67
|
const req: SaveTableRequest = {
|
|
68
|
-
name: uuid.v4().substring(0,
|
|
68
|
+
name: uuid.v4().substring(0, 10),
|
|
69
69
|
type: "table",
|
|
70
70
|
sourceType: datasource
|
|
71
71
|
? TableSourceType.EXTERNAL
|
|
@@ -87,7 +87,10 @@ describe.each([
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function defaultTable(
|
|
90
|
-
|
|
90
|
+
// We omit the name field here because it's generated in the function with a
|
|
91
|
+
// high likelihood to be unique. Tests should not have any reason to control
|
|
92
|
+
// the table name they're writing to.
|
|
93
|
+
...overrides: Partial<Omit<SaveTableRequest, "name">>[]
|
|
91
94
|
): SaveTableRequest {
|
|
92
95
|
return saveTableRequest(
|
|
93
96
|
{
|
|
@@ -194,7 +197,6 @@ describe.each([
|
|
|
194
197
|
|
|
195
198
|
const newTable = await config.api.table.save(
|
|
196
199
|
saveTableRequest({
|
|
197
|
-
name: "TestTableAuto",
|
|
198
200
|
schema: {
|
|
199
201
|
"Row ID": {
|
|
200
202
|
name: "Row ID",
|
|
@@ -383,11 +385,9 @@ describe.each([
|
|
|
383
385
|
|
|
384
386
|
isInternal &&
|
|
385
387
|
it("doesn't allow creating in user table", async () => {
|
|
386
|
-
const userTableId = InternalTable.USER_METADATA
|
|
387
388
|
const response = await config.api.row.save(
|
|
388
|
-
|
|
389
|
+
InternalTable.USER_METADATA,
|
|
389
390
|
{
|
|
390
|
-
tableId: userTableId,
|
|
391
391
|
firstName: "Joe",
|
|
392
392
|
lastName: "Joe",
|
|
393
393
|
email: "joe@joe.com",
|
|
@@ -462,7 +462,6 @@ describe.each([
|
|
|
462
462
|
table = await config.api.table.save(defaultTable())
|
|
463
463
|
otherTable = await config.api.table.save(
|
|
464
464
|
defaultTable({
|
|
465
|
-
name: "a",
|
|
466
465
|
schema: {
|
|
467
466
|
relationship: {
|
|
468
467
|
name: "relationship",
|
|
@@ -898,8 +897,8 @@ describe.each([
|
|
|
898
897
|
let o2mTable: Table
|
|
899
898
|
let m2mTable: Table
|
|
900
899
|
beforeAll(async () => {
|
|
901
|
-
o2mTable = await config.api.table.save(defaultTable(
|
|
902
|
-
m2mTable = await config.api.table.save(defaultTable(
|
|
900
|
+
o2mTable = await config.api.table.save(defaultTable())
|
|
901
|
+
m2mTable = await config.api.table.save(defaultTable())
|
|
903
902
|
})
|
|
904
903
|
|
|
905
904
|
describe.each([
|
|
@@ -1256,7 +1255,6 @@ describe.each([
|
|
|
1256
1255
|
otherTable = await config.api.table.save(defaultTable())
|
|
1257
1256
|
table = await config.api.table.save(
|
|
1258
1257
|
saveTableRequest({
|
|
1259
|
-
name: "b",
|
|
1260
1258
|
schema: {
|
|
1261
1259
|
links: {
|
|
1262
1260
|
name: "links",
|
|
@@ -1354,7 +1352,6 @@ describe.each([
|
|
|
1354
1352
|
|
|
1355
1353
|
const table = await config.api.table.save(
|
|
1356
1354
|
saveTableRequest({
|
|
1357
|
-
name: "table",
|
|
1358
1355
|
schema: {
|
|
1359
1356
|
text: {
|
|
1360
1357
|
name: "text",
|
|
@@ -3,8 +3,6 @@ import { checkPermissionsEndpoint } from "./utilities/TestFunctions"
|
|
|
3
3
|
import * as setup from "./utilities"
|
|
4
4
|
import { UserMetadata } from "@budibase/types"
|
|
5
5
|
|
|
6
|
-
jest.setTimeout(30000)
|
|
7
|
-
|
|
8
6
|
jest.mock("../../../utilities/workerRequests", () => ({
|
|
9
7
|
getGlobalUsers: jest.fn(() => {
|
|
10
8
|
return {}
|
|
@@ -19,8 +19,7 @@ import {
|
|
|
19
19
|
ViewV2,
|
|
20
20
|
} from "@budibase/types"
|
|
21
21
|
import { generator, mocks } from "@budibase/backend-core/tests"
|
|
22
|
-
import
|
|
23
|
-
import { databaseTestProviders } from "../../../integrations/tests/utils"
|
|
22
|
+
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
|
24
23
|
import merge from "lodash/merge"
|
|
25
24
|
import { quotas } from "@budibase/pro"
|
|
26
25
|
import { roles } from "@budibase/backend-core"
|
|
@@ -30,10 +29,10 @@ jest.unmock("pg")
|
|
|
30
29
|
|
|
31
30
|
describe.each([
|
|
32
31
|
["internal", undefined],
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
32
|
+
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
|
|
33
|
+
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
|
|
34
|
+
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
|
|
35
|
+
[DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
|
|
37
36
|
])("/v2/views (%s)", (_, dsProvider) => {
|
|
38
37
|
const config = setup.getConfig()
|
|
39
38
|
const isInternal = !dsProvider
|
|
@@ -42,10 +41,10 @@ describe.each([
|
|
|
42
41
|
let datasource: Datasource
|
|
43
42
|
|
|
44
43
|
function saveTableRequest(
|
|
45
|
-
...overrides: Partial<SaveTableRequest
|
|
44
|
+
...overrides: Partial<Omit<SaveTableRequest, "name">>[]
|
|
46
45
|
): SaveTableRequest {
|
|
47
46
|
const req: SaveTableRequest = {
|
|
48
|
-
name:
|
|
47
|
+
name: generator.guid().replaceAll("-", "").substring(0, 16),
|
|
49
48
|
type: "table",
|
|
50
49
|
sourceType: datasource
|
|
51
50
|
? TableSourceType.EXTERNAL
|
|
@@ -90,16 +89,13 @@ describe.each([
|
|
|
90
89
|
|
|
91
90
|
if (dsProvider) {
|
|
92
91
|
datasource = await config.createDatasource({
|
|
93
|
-
datasource: await dsProvider
|
|
92
|
+
datasource: await dsProvider,
|
|
94
93
|
})
|
|
95
94
|
}
|
|
96
95
|
table = await config.api.table.save(priceTable())
|
|
97
96
|
})
|
|
98
97
|
|
|
99
98
|
afterAll(async () => {
|
|
100
|
-
if (dsProvider) {
|
|
101
|
-
await dsProvider.stop()
|
|
102
|
-
}
|
|
103
99
|
setup.afterAll()
|
|
104
100
|
})
|
|
105
101
|
|
|
@@ -231,7 +227,7 @@ describe.each([
|
|
|
231
227
|
|
|
232
228
|
view = await config.api.viewV2.create({
|
|
233
229
|
tableId: table._id!,
|
|
234
|
-
name:
|
|
230
|
+
name: generator.guid(),
|
|
235
231
|
})
|
|
236
232
|
})
|
|
237
233
|
|
|
@@ -307,12 +303,13 @@ describe.each([
|
|
|
307
303
|
|
|
308
304
|
it("can update an existing view name", async () => {
|
|
309
305
|
const tableId = table._id!
|
|
310
|
-
|
|
306
|
+
const newName = generator.guid()
|
|
307
|
+
await config.api.viewV2.update({ ...view, name: newName })
|
|
311
308
|
|
|
312
309
|
expect(await config.api.table.get(tableId)).toEqual(
|
|
313
310
|
expect.objectContaining({
|
|
314
311
|
views: {
|
|
315
|
-
|
|
312
|
+
[newName]: { ...view, name: newName, schema: expect.anything() },
|
|
316
313
|
},
|
|
317
314
|
})
|
|
318
315
|
)
|
|
@@ -507,7 +504,6 @@ describe.each([
|
|
|
507
504
|
it("views have extra data trimmed", async () => {
|
|
508
505
|
const table = await config.api.table.save(
|
|
509
506
|
saveTableRequest({
|
|
510
|
-
name: "orders",
|
|
511
507
|
schema: {
|
|
512
508
|
Country: {
|
|
513
509
|
type: FieldType.STRING,
|
|
@@ -523,7 +519,7 @@ describe.each([
|
|
|
523
519
|
|
|
524
520
|
const view = await config.api.viewV2.create({
|
|
525
521
|
tableId: table._id!,
|
|
526
|
-
name:
|
|
522
|
+
name: generator.guid(),
|
|
527
523
|
schema: {
|
|
528
524
|
Country: {
|
|
529
525
|
visible: true,
|
|
@@ -853,7 +849,6 @@ describe.each([
|
|
|
853
849
|
beforeAll(async () => {
|
|
854
850
|
table = await config.api.table.save(
|
|
855
851
|
saveTableRequest({
|
|
856
|
-
name: `users_${uuid.v4()}`,
|
|
857
852
|
type: "table",
|
|
858
853
|
schema: {
|
|
859
854
|
name: {
|