@budibase/server 1.3.21 → 1.3.22-alpha.1
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/__mocks__/mongodb.ts +1 -1
- package/builder/assets/index.96c69636.js +1008 -0
- package/builder/assets/index.c167b5c3.css +6 -0
- package/builder/index.html +2 -4
- package/coverage/clover.xml +308 -338
- package/coverage/coverage-final.json +19 -21
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +41 -8
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +73 -34
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +27 -57
- package/coverage/lcov-report/api/controllers/integration.js.html +6 -6
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +13 -13
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +9 -9
- package/coverage/lcov-report/api/routes/utils/validators.js.html +75 -12
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +14 -14
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +30 -18
- package/coverage/lcov-report/events/AutomationEmitter.js.html +3 -3
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +44 -44
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +46 -40
- package/coverage/lcov-report/middleware/index.html +15 -15
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +15 -15
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +32 -8
- package/coverage/lcov.info +521 -558
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +9 -0
- package/dist/api/controllers/component.js +19 -6
- package/dist/api/controllers/datasource.js +21 -8
- package/dist/api/controllers/deploy/index.js +1 -8
- package/dist/api/controllers/integration.js +4 -4
- package/dist/{migrations/functions/usageQuotas/syncDevelopers.js → api/controllers/plugin/file.js} +13 -13
- package/dist/api/controllers/plugin/github.js +69 -0
- package/dist/api/controllers/plugin/index.js +144 -0
- package/dist/api/controllers/plugin/npm.js +58 -0
- package/dist/api/controllers/plugin/uploaders.js +11 -0
- package/dist/{migrations/functions/usageQuotas/syncPublishedApps.js → api/controllers/plugin/url.js} +13 -15
- package/dist/api/controllers/plugin/utils.js +26 -0
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +62 -14
- package/dist/api/controllers/static/index.js +1 -0
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/dist/api/controllers/static/templates/preview.hbs +5 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +3 -2
- package/dist/api/routes/index.js +2 -0
- package/dist/{migrations/functions/publishedAppsQuota.js → api/routes/plugin.js} +13 -21
- package/dist/api/routes/public/rows.js +1 -82
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +20 -2
- package/dist/app.js +16 -1
- package/dist/db/utils.js +3 -0
- package/dist/environment.js +1 -0
- package/dist/integrations/airtable.js +126 -129
- package/dist/integrations/arangodb.js +86 -89
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +3 -1
- package/dist/integrations/couchdb.js +80 -83
- package/dist/integrations/dynamodb.js +161 -164
- package/dist/integrations/elasticsearch.js +135 -138
- package/dist/integrations/firebase.js +154 -157
- package/dist/integrations/googlesheets.js +323 -327
- package/dist/integrations/index.js +99 -51
- package/dist/integrations/microsoftSqlServer.js +240 -243
- package/dist/integrations/mongodb.js +239 -242
- package/dist/integrations/mysql.js +215 -219
- package/dist/integrations/oracle.js +318 -322
- package/dist/integrations/postgres.js +262 -265
- package/dist/integrations/redis.js +134 -139
- package/dist/integrations/rest.js +289 -292
- package/dist/integrations/s3.js +61 -64
- package/dist/integrations/snowflake.js +83 -86
- package/dist/middleware/currentapp.js +2 -0
- package/dist/migrations/functions/backfill/global.js +0 -3
- package/dist/migrations/index.js +0 -10
- package/dist/package.json +9 -6
- package/dist/tests/utilities/TestConfiguration.js +1 -1
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +105 -1
- package/dist/utilities/workerRequests.js +4 -0
- package/dist/watch.js +77 -0
- package/dist/websocket.js +22 -0
- package/package.json +10 -7
- package/scripts/dev/manage.js +4 -0
- package/scripts/localdomain.js +3 -1
- package/specs/openapi.json +115 -112
- package/specs/openapi.yaml +96 -94
- package/specs/resources/misc.js +116 -0
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +1 -2
- package/src/api/controllers/auth.js +11 -0
- package/src/api/controllers/component.ts +57 -0
- package/src/api/controllers/datasource.js +21 -8
- package/src/api/controllers/deploy/index.ts +1 -6
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/plugin/file.ts +15 -0
- package/src/api/controllers/plugin/github.ts +75 -0
- package/src/api/controllers/plugin/index.ts +134 -0
- package/src/api/controllers/plugin/npm.ts +56 -0
- package/src/api/controllers/plugin/uploaders.ts +4 -0
- package/src/api/controllers/plugin/url.ts +12 -0
- package/src/api/controllers/plugin/utils.ts +19 -0
- package/src/api/controllers/public/mapping/types.ts +8 -0
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.ts +122 -0
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/src/api/controllers/static/templates/preview.hbs +5 -1
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +13 -2
- package/src/api/routes/index.ts +2 -0
- package/src/api/routes/plugin.ts +14 -0
- package/src/api/routes/public/rows.ts +1 -82
- package/src/api/routes/public/tables.ts +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/tests/query.spec.js +8 -25
- package/src/api/routes/tests/user.spec.js +0 -2
- package/src/api/routes/utils/validators.js +26 -5
- package/src/app.ts +25 -2
- package/src/db/utils.js +4 -0
- package/src/definitions/openapi.ts +56 -55
- package/src/environment.js +1 -0
- package/src/integrations/airtable.ts +116 -118
- package/src/integrations/arangodb.ts +87 -89
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +3 -1
- package/src/integrations/couchdb.ts +83 -89
- package/src/integrations/dynamodb.ts +173 -175
- package/src/integrations/elasticsearch.ts +120 -122
- package/src/integrations/firebase.ts +157 -159
- package/src/integrations/googlesheets.ts +328 -338
- package/src/integrations/index.ts +64 -21
- package/src/integrations/microsoftSqlServer.ts +249 -251
- package/src/integrations/mongodb.ts +261 -258
- package/src/integrations/mysql.ts +229 -234
- package/src/integrations/oracle.ts +373 -380
- package/src/integrations/postgres.ts +264 -268
- package/src/integrations/redis.ts +128 -132
- package/src/integrations/rest.ts +324 -329
- package/src/integrations/s3.ts +68 -71
- package/src/integrations/snowflake.ts +80 -82
- package/src/integrations/tests/{airtable.spec.js → airtable.spec.ts} +21 -18
- package/src/integrations/tests/{arangodb.spec.js → arangodb.spec.ts} +12 -9
- package/src/integrations/tests/{couchdb.spec.js → couchdb.spec.ts} +33 -27
- package/src/integrations/tests/{dynamodb.spec.js → dynamodb.spec.ts} +45 -41
- package/src/integrations/tests/{elasticsearch.spec.js → elasticsearch.spec.ts} +22 -21
- package/src/integrations/tests/{firebase.spec.js → firebase.spec.ts} +33 -28
- package/src/integrations/tests/{microsoftSqlServer.spec.js → microsoftSqlServer.spec.ts} +12 -11
- package/src/integrations/tests/{mongo.spec.js → mongo.spec.ts} +46 -35
- package/src/integrations/tests/{mysql.spec.js → mysql.spec.ts} +17 -15
- package/src/integrations/tests/{oracle.spec.js → oracle.spec.ts} +19 -17
- package/src/integrations/tests/{postgres.spec.js → postgres.spec.ts} +19 -17
- package/src/integrations/tests/{redis.spec.js → redis.spec.ts} +27 -18
- package/src/integrations/tests/{rest.spec.js → rest.spec.ts} +22 -14
- package/src/integrations/tests/{s3.spec.js → s3.spec.ts} +10 -8
- package/src/integrations/tests/{sql.spec.js → sql.spec.ts} +228 -177
- package/src/middleware/currentapp.js +2 -0
- package/src/migrations/functions/backfill/global.ts +0 -3
- package/src/migrations/index.ts +0 -16
- package/src/module.d.ts +2 -0
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +123 -0
- package/src/utilities/workerRequests.js +8 -0
- package/src/watch.ts +38 -0
- package/src/websocket.ts +26 -0
- package/builder/assets/index.8d12d461.css +0 -6
- package/builder/assets/index.d354271c.js +0 -879
- package/builder/assets/vendor.5e1fe644.css +0 -1
- package/builder/assets/vendor.67dbd8fa.js +0 -248
- package/coverage/lcov-report/api/controllers/component.js.html +0 -199
- package/coverage/lcov-report/api/controllers/screen.js.html +0 -259
- package/dist/migrations/functions/developerQuota.js +0 -49
- package/src/api/controllers/component.js +0 -38
- package/src/api/controllers/screen.js +0 -58
- package/src/migrations/functions/developerQuota.ts +0 -15
- package/src/migrations/functions/publishedAppsQuota.ts +0 -13
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +0 -19
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +0 -21
|
@@ -3,7 +3,7 @@ const { SqlClient } = require("../utils")
|
|
|
3
3
|
|
|
4
4
|
const TABLE_NAME = "test"
|
|
5
5
|
|
|
6
|
-
function endpoint(table, operation) {
|
|
6
|
+
function endpoint(table: any, operation: any) {
|
|
7
7
|
return {
|
|
8
8
|
datasourceId: "Postgres",
|
|
9
9
|
operation: operation,
|
|
@@ -11,7 +11,13 @@ function endpoint(table, operation) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function generateReadJson({
|
|
14
|
+
function generateReadJson({
|
|
15
|
+
table,
|
|
16
|
+
fields,
|
|
17
|
+
filters,
|
|
18
|
+
sort,
|
|
19
|
+
paginate,
|
|
20
|
+
}: any = {}) {
|
|
15
21
|
return {
|
|
16
22
|
endpoint: endpoint(table || TABLE_NAME, "READ"),
|
|
17
23
|
resource: {
|
|
@@ -48,7 +54,7 @@ function generateDeleteJson(table = TABLE_NAME, filters = {}) {
|
|
|
48
54
|
describe("SQL query builder", () => {
|
|
49
55
|
const limit = 500
|
|
50
56
|
const client = SqlClient.POSTGRES
|
|
51
|
-
let sql
|
|
57
|
+
let sql: any
|
|
52
58
|
|
|
53
59
|
beforeEach(() => {
|
|
54
60
|
sql = new Sql(client, limit)
|
|
@@ -58,118 +64,139 @@ describe("SQL query builder", () => {
|
|
|
58
64
|
const query = sql._query(generateReadJson())
|
|
59
65
|
expect(query).toEqual({
|
|
60
66
|
bindings: [limit],
|
|
61
|
-
sql: `select * from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"
|
|
67
|
+
sql: `select * from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"`,
|
|
62
68
|
})
|
|
63
69
|
})
|
|
64
70
|
|
|
65
71
|
it("should test a read with specific columns", () => {
|
|
66
|
-
const nameProp = `${TABLE_NAME}.name`,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
const nameProp = `${TABLE_NAME}.name`,
|
|
73
|
+
ageProp = `${TABLE_NAME}.age`
|
|
74
|
+
const query = sql._query(
|
|
75
|
+
generateReadJson({
|
|
76
|
+
fields: [nameProp, ageProp],
|
|
77
|
+
})
|
|
78
|
+
)
|
|
70
79
|
expect(query).toEqual({
|
|
71
80
|
bindings: [limit],
|
|
72
|
-
sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"
|
|
81
|
+
sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"`,
|
|
73
82
|
})
|
|
74
83
|
})
|
|
75
84
|
|
|
76
85
|
it("should test a where string starts with read", () => {
|
|
77
|
-
const query = sql._query(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
const query = sql._query(
|
|
87
|
+
generateReadJson({
|
|
88
|
+
filters: {
|
|
89
|
+
string: {
|
|
90
|
+
name: "John",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
)
|
|
84
95
|
expect(query).toEqual({
|
|
85
96
|
bindings: ["John%", limit],
|
|
86
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2) as "${TABLE_NAME}"
|
|
97
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2) as "${TABLE_NAME}"`,
|
|
87
98
|
})
|
|
88
99
|
})
|
|
89
100
|
|
|
90
101
|
it("should test a where range read", () => {
|
|
91
|
-
const query = sql._query(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
const query = sql._query(
|
|
103
|
+
generateReadJson({
|
|
104
|
+
filters: {
|
|
105
|
+
range: {
|
|
106
|
+
age: {
|
|
107
|
+
low: 2,
|
|
108
|
+
high: 10,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
)
|
|
101
114
|
expect(query).toEqual({
|
|
102
115
|
bindings: [2, 10, limit],
|
|
103
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" between $1 and $2 limit $3) as "${TABLE_NAME}"
|
|
116
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" between $1 and $2 limit $3) as "${TABLE_NAME}"`,
|
|
104
117
|
})
|
|
105
118
|
})
|
|
106
119
|
|
|
107
120
|
it("should test for multiple IDs with OR", () => {
|
|
108
|
-
const query = sql._query(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
121
|
+
const query = sql._query(
|
|
122
|
+
generateReadJson({
|
|
123
|
+
filters: {
|
|
124
|
+
equal: {
|
|
125
|
+
age: 10,
|
|
126
|
+
name: "John",
|
|
127
|
+
},
|
|
128
|
+
allOr: true,
|
|
113
129
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}))
|
|
130
|
+
})
|
|
131
|
+
)
|
|
117
132
|
expect(query).toEqual({
|
|
118
133
|
bindings: [10, "John", limit],
|
|
119
|
-
sql: `select * from (select * from "${TABLE_NAME}" where ("${TABLE_NAME}"."age" = $1) or ("${TABLE_NAME}"."name" = $2) limit $3) as "${TABLE_NAME}"
|
|
134
|
+
sql: `select * from (select * from "${TABLE_NAME}" where ("${TABLE_NAME}"."age" = $1) or ("${TABLE_NAME}"."name" = $2) limit $3) as "${TABLE_NAME}"`,
|
|
120
135
|
})
|
|
121
136
|
})
|
|
122
137
|
|
|
123
138
|
it("should allow filtering on a related field", () => {
|
|
124
|
-
const query = sql._query(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
const query = sql._query(
|
|
140
|
+
generateReadJson({
|
|
141
|
+
filters: {
|
|
142
|
+
equal: {
|
|
143
|
+
age: 10,
|
|
144
|
+
"task.name": "task 1",
|
|
145
|
+
},
|
|
129
146
|
},
|
|
130
|
-
}
|
|
131
|
-
|
|
147
|
+
})
|
|
148
|
+
)
|
|
132
149
|
// order of bindings changes because relationship filters occur outside inner query
|
|
133
150
|
expect(query).toEqual({
|
|
134
151
|
bindings: [10, limit, "task 1"],
|
|
135
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3
|
|
152
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3`,
|
|
136
153
|
})
|
|
137
154
|
})
|
|
138
155
|
|
|
139
156
|
it("should test an create statement", () => {
|
|
140
|
-
const query = sql._query(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
const query = sql._query(
|
|
158
|
+
generateCreateJson(TABLE_NAME, {
|
|
159
|
+
name: "Michael",
|
|
160
|
+
age: 45,
|
|
161
|
+
})
|
|
162
|
+
)
|
|
144
163
|
expect(query).toEqual({
|
|
145
164
|
bindings: [45, "Michael"],
|
|
146
|
-
sql: `insert into "${TABLE_NAME}" ("age", "name") values ($1, $2) returning
|
|
165
|
+
sql: `insert into "${TABLE_NAME}" ("age", "name") values ($1, $2) returning *`,
|
|
147
166
|
})
|
|
148
167
|
})
|
|
149
168
|
|
|
150
169
|
it("should test an update statement", () => {
|
|
151
|
-
const query = sql._query(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
170
|
+
const query = sql._query(
|
|
171
|
+
generateUpdateJson(
|
|
172
|
+
TABLE_NAME,
|
|
173
|
+
{
|
|
174
|
+
name: "John",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
equal: {
|
|
178
|
+
id: 1001,
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
)
|
|
158
183
|
expect(query).toEqual({
|
|
159
184
|
bindings: ["John", 1001],
|
|
160
|
-
sql: `update "${TABLE_NAME}" set "name" = $1 where "${TABLE_NAME}"."id" = $2 returning
|
|
185
|
+
sql: `update "${TABLE_NAME}" set "name" = $1 where "${TABLE_NAME}"."id" = $2 returning *`,
|
|
161
186
|
})
|
|
162
187
|
})
|
|
163
188
|
|
|
164
189
|
it("should test a delete statement", () => {
|
|
165
|
-
const query = sql._query(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
190
|
+
const query = sql._query(
|
|
191
|
+
generateDeleteJson(TABLE_NAME, {
|
|
192
|
+
equal: {
|
|
193
|
+
id: 1001,
|
|
194
|
+
},
|
|
195
|
+
})
|
|
196
|
+
)
|
|
170
197
|
expect(query).toEqual({
|
|
171
198
|
bindings: [1001],
|
|
172
|
-
sql: `delete from "${TABLE_NAME}" where "${TABLE_NAME}"."id" = $1 returning
|
|
199
|
+
sql: `delete from "${TABLE_NAME}" where "${TABLE_NAME}"."id" = $1 returning *`,
|
|
173
200
|
})
|
|
174
201
|
})
|
|
175
202
|
|
|
@@ -177,7 +204,7 @@ describe("SQL query builder", () => {
|
|
|
177
204
|
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson())
|
|
178
205
|
expect(query).toEqual({
|
|
179
206
|
bindings: [10],
|
|
180
|
-
sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]
|
|
207
|
+
sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]`,
|
|
181
208
|
})
|
|
182
209
|
})
|
|
183
210
|
|
|
@@ -185,193 +212,217 @@ describe("SQL query builder", () => {
|
|
|
185
212
|
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson())
|
|
186
213
|
expect(query).toEqual({
|
|
187
214
|
bindings: [10],
|
|
188
|
-
sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}
|
|
215
|
+
sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\``,
|
|
189
216
|
})
|
|
190
217
|
})
|
|
191
218
|
|
|
192
219
|
it("should use greater than when only low range specified", () => {
|
|
193
220
|
const date = new Date()
|
|
194
|
-
const query = sql._query(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
221
|
+
const query = sql._query(
|
|
222
|
+
generateReadJson({
|
|
223
|
+
filters: {
|
|
224
|
+
range: {
|
|
225
|
+
property: {
|
|
226
|
+
low: date,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
})
|
|
231
|
+
)
|
|
203
232
|
expect(query).toEqual({
|
|
204
233
|
bindings: [date, limit],
|
|
205
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"
|
|
234
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`,
|
|
206
235
|
})
|
|
207
236
|
})
|
|
208
237
|
|
|
209
238
|
it("should use less than when only high range specified", () => {
|
|
210
239
|
const date = new Date()
|
|
211
|
-
const query = sql._query(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
240
|
+
const query = sql._query(
|
|
241
|
+
generateReadJson({
|
|
242
|
+
filters: {
|
|
243
|
+
range: {
|
|
244
|
+
property: {
|
|
245
|
+
high: date,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
)
|
|
220
251
|
expect(query).toEqual({
|
|
221
252
|
bindings: [date, limit],
|
|
222
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" < $1 limit $2) as "${TABLE_NAME}"
|
|
253
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" < $1 limit $2) as "${TABLE_NAME}"`,
|
|
223
254
|
})
|
|
224
255
|
})
|
|
225
256
|
|
|
226
257
|
it("should use greater than when only low range specified", () => {
|
|
227
258
|
const date = new Date()
|
|
228
|
-
const query = sql._query(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
259
|
+
const query = sql._query(
|
|
260
|
+
generateReadJson({
|
|
261
|
+
filters: {
|
|
262
|
+
range: {
|
|
263
|
+
property: {
|
|
264
|
+
low: date,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
})
|
|
269
|
+
)
|
|
237
270
|
expect(query).toEqual({
|
|
238
271
|
bindings: [date, limit],
|
|
239
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"
|
|
272
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`,
|
|
240
273
|
})
|
|
241
274
|
})
|
|
242
275
|
|
|
243
276
|
it("should use AND like expression for MS-SQL when filter is contains", () => {
|
|
244
|
-
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
277
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
278
|
+
generateReadJson({
|
|
279
|
+
filters: {
|
|
280
|
+
contains: {
|
|
281
|
+
age: [20, 25],
|
|
282
|
+
name: ["John", "Mary"],
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
})
|
|
286
|
+
)
|
|
252
287
|
expect(query).toEqual({
|
|
253
288
|
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`],
|
|
254
|
-
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 AND LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 AND LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]
|
|
289
|
+
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 AND LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 AND LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]`,
|
|
255
290
|
})
|
|
256
291
|
})
|
|
257
292
|
|
|
258
293
|
it("should use JSON_CONTAINS expression for MySQL when filter is contains", () => {
|
|
259
|
-
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
294
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
295
|
+
generateReadJson({
|
|
296
|
+
filters: {
|
|
297
|
+
contains: {
|
|
298
|
+
age: [20],
|
|
299
|
+
name: ["John"],
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
})
|
|
303
|
+
)
|
|
267
304
|
expect(query).toEqual({
|
|
268
305
|
bindings: [10],
|
|
269
|
-
sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}
|
|
306
|
+
sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}\``,
|
|
270
307
|
})
|
|
271
308
|
})
|
|
272
309
|
|
|
273
310
|
it("should use jsonb operator expression for PostgreSQL when filter is contains", () => {
|
|
274
|
-
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
311
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
312
|
+
generateReadJson({
|
|
313
|
+
filters: {
|
|
314
|
+
contains: {
|
|
315
|
+
age: [20],
|
|
316
|
+
name: ["John"],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
})
|
|
320
|
+
)
|
|
282
321
|
expect(query).toEqual({
|
|
283
322
|
bindings: [10],
|
|
284
|
-
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"
|
|
323
|
+
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`,
|
|
285
324
|
})
|
|
286
325
|
})
|
|
287
326
|
|
|
288
327
|
it("should use NOT like expression for MS-SQL when filter is notContains", () => {
|
|
289
|
-
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
328
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
329
|
+
generateReadJson({
|
|
330
|
+
filters: {
|
|
331
|
+
notContains: {
|
|
332
|
+
age: [20],
|
|
333
|
+
name: ["John"],
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
})
|
|
337
|
+
)
|
|
297
338
|
expect(query).toEqual({
|
|
298
339
|
bindings: [10, "%20%", `%"John"%`],
|
|
299
|
-
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where NOT (LOWER(${TABLE_NAME}.age) LIKE @p1) and NOT (LOWER(${TABLE_NAME}.name) LIKE @p2)) as [${TABLE_NAME}]
|
|
340
|
+
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where NOT (LOWER(${TABLE_NAME}.age) LIKE @p1) and NOT (LOWER(${TABLE_NAME}.name) LIKE @p2)) as [${TABLE_NAME}]`,
|
|
300
341
|
})
|
|
301
342
|
})
|
|
302
343
|
|
|
303
344
|
it("should use NOT JSON_CONTAINS expression for MySQL when filter is notContains", () => {
|
|
304
|
-
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
345
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
346
|
+
generateReadJson({
|
|
347
|
+
filters: {
|
|
348
|
+
notContains: {
|
|
349
|
+
age: [20],
|
|
350
|
+
name: ["John"],
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
})
|
|
354
|
+
)
|
|
312
355
|
expect(query).toEqual({
|
|
313
356
|
bindings: [10],
|
|
314
|
-
sql: `select * from (select * from \`${TABLE_NAME}\` where NOT JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and NOT JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}
|
|
357
|
+
sql: `select * from (select * from \`${TABLE_NAME}\` where NOT JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and NOT JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}\``,
|
|
315
358
|
})
|
|
316
359
|
})
|
|
317
360
|
|
|
318
361
|
it("should use jsonb operator NOT expression for PostgreSQL when filter is notContains", () => {
|
|
319
|
-
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
362
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
363
|
+
generateReadJson({
|
|
364
|
+
filters: {
|
|
365
|
+
notContains: {
|
|
366
|
+
age: [20],
|
|
367
|
+
name: ["John"],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
})
|
|
371
|
+
)
|
|
327
372
|
expect(query).toEqual({
|
|
328
373
|
bindings: [10],
|
|
329
|
-
sql: `select * from (select * from \"${TABLE_NAME}\" where NOT \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and NOT \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"
|
|
374
|
+
sql: `select * from (select * from \"${TABLE_NAME}\" where NOT \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and NOT \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`,
|
|
330
375
|
})
|
|
331
376
|
})
|
|
332
377
|
|
|
333
378
|
it("should use OR like expression for MS-SQL when filter is containsAny", () => {
|
|
334
|
-
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
379
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
380
|
+
generateReadJson({
|
|
381
|
+
filters: {
|
|
382
|
+
containsAny: {
|
|
383
|
+
age: [20, 25],
|
|
384
|
+
name: ["John", "Mary"],
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
})
|
|
388
|
+
)
|
|
342
389
|
expect(query).toEqual({
|
|
343
390
|
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`],
|
|
344
|
-
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 OR LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 OR LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]
|
|
391
|
+
sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 OR LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 OR LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]`,
|
|
345
392
|
})
|
|
346
393
|
})
|
|
347
394
|
|
|
348
395
|
it("should use JSON_OVERLAPS expression for MySQL when filter is containsAny", () => {
|
|
349
|
-
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
396
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
397
|
+
generateReadJson({
|
|
398
|
+
filters: {
|
|
399
|
+
containsAny: {
|
|
400
|
+
age: [20, 25],
|
|
401
|
+
name: ["John", "Mary"],
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
})
|
|
405
|
+
)
|
|
357
406
|
expect(query).toEqual({
|
|
358
407
|
bindings: [10],
|
|
359
|
-
sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_OVERLAPS(${TABLE_NAME}.age, '[20,25]') and JSON_OVERLAPS(${TABLE_NAME}.name, '["John","Mary"]') limit ?) as \`${TABLE_NAME}
|
|
408
|
+
sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_OVERLAPS(${TABLE_NAME}.age, '[20,25]') and JSON_OVERLAPS(${TABLE_NAME}.name, '["John","Mary"]') limit ?) as \`${TABLE_NAME}\``,
|
|
360
409
|
})
|
|
361
410
|
})
|
|
362
411
|
|
|
363
412
|
it("should use ?| operator expression for PostgreSQL when filter is containsAny", () => {
|
|
364
|
-
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
413
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
414
|
+
generateReadJson({
|
|
415
|
+
filters: {
|
|
416
|
+
containsAny: {
|
|
417
|
+
age: [20, 25],
|
|
418
|
+
name: ["John", "Mary"],
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
})
|
|
422
|
+
)
|
|
372
423
|
expect(query).toEqual({
|
|
373
424
|
bindings: [10],
|
|
374
|
-
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb ?| array [20,25] and \"${TABLE_NAME}\".\"name\"::jsonb ?| array ['John','Mary'] limit $1) as \"${TABLE_NAME}\"
|
|
425
|
+
sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb ?| array [20,25] and \"${TABLE_NAME}\".\"name\"::jsonb ?| array ['John','Mary'] limit $1) as \"${TABLE_NAME}\"`,
|
|
375
426
|
})
|
|
376
427
|
})
|
|
377
428
|
})
|
|
@@ -111,12 +111,14 @@ module.exports = async (ctx, next) => {
|
|
|
111
111
|
ctx.appId = appId
|
|
112
112
|
if (roleId) {
|
|
113
113
|
ctx.roleId = roleId
|
|
114
|
+
const globalId = ctx.user ? ctx.user._id : undefined
|
|
114
115
|
const userId = ctx.user ? generateUserMetadataID(ctx.user._id) : null
|
|
115
116
|
ctx.user = {
|
|
116
117
|
...ctx.user,
|
|
117
118
|
// override userID with metadata one
|
|
118
119
|
_id: userId,
|
|
119
120
|
userId,
|
|
121
|
+
globalId,
|
|
120
122
|
roleId,
|
|
121
123
|
role: await getRole(roleId),
|
|
122
124
|
}
|
|
@@ -35,12 +35,10 @@ const formatUsage = (usage: QuotaUsage) => {
|
|
|
35
35
|
let maxAutomations = 0
|
|
36
36
|
let maxQueries = 0
|
|
37
37
|
let rows = 0
|
|
38
|
-
let developers = 0
|
|
39
38
|
|
|
40
39
|
if (usage) {
|
|
41
40
|
if (usage.usageQuota) {
|
|
42
41
|
rows = usage.usageQuota.rows
|
|
43
|
-
developers = usage.usageQuota.developers
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
if (usage.monthly) {
|
|
@@ -59,7 +57,6 @@ const formatUsage = (usage: QuotaUsage) => {
|
|
|
59
57
|
maxAutomations,
|
|
60
58
|
maxQueries,
|
|
61
59
|
rows,
|
|
62
|
-
developers,
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
62
|
|
package/src/migrations/index.ts
CHANGED
|
@@ -6,8 +6,6 @@ import env from "../environment"
|
|
|
6
6
|
import * as userEmailViewCasing from "./functions/userEmailViewCasing"
|
|
7
7
|
import * as quota1 from "./functions/quotas1"
|
|
8
8
|
import * as appUrls from "./functions/appUrls"
|
|
9
|
-
import * as developerQuota from "./functions/developerQuota"
|
|
10
|
-
import * as publishedAppsQuota from "./functions/publishedAppsQuota"
|
|
11
9
|
import * as backfill from "./functions/backfill"
|
|
12
10
|
|
|
13
11
|
/**
|
|
@@ -42,20 +40,6 @@ export const buildMigrations = () => {
|
|
|
42
40
|
})
|
|
43
41
|
break
|
|
44
42
|
}
|
|
45
|
-
case MigrationName.DEVELOPER_QUOTA: {
|
|
46
|
-
serverMigrations.push({
|
|
47
|
-
...definition,
|
|
48
|
-
fn: developerQuota.run,
|
|
49
|
-
})
|
|
50
|
-
break
|
|
51
|
-
}
|
|
52
|
-
case MigrationName.PUBLISHED_APP_QUOTA: {
|
|
53
|
-
serverMigrations.push({
|
|
54
|
-
...definition,
|
|
55
|
-
fn: publishedAppsQuota.run,
|
|
56
|
-
})
|
|
57
|
-
break
|
|
58
|
-
}
|
|
59
43
|
case MigrationName.EVENT_APP_BACKFILL: {
|
|
60
44
|
serverMigrations.push({
|
|
61
45
|
...definition,
|
package/src/module.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ declare module "@budibase/backend-core/sessions"
|
|
|
10
10
|
declare module "@budibase/backend-core/encryption"
|
|
11
11
|
declare module "@budibase/backend-core/utils"
|
|
12
12
|
declare module "@budibase/backend-core/redis"
|
|
13
|
+
declare module "@budibase/backend-core/objectStore"
|
|
14
|
+
declare module "@budibase/backend-core/plugins"
|
|
@@ -560,7 +560,7 @@ class TestConfiguration {
|
|
|
560
560
|
|
|
561
561
|
async createQuery(config = null) {
|
|
562
562
|
if (!this.datasource && !config) {
|
|
563
|
-
throw "No
|
|
563
|
+
throw "No datasource created for query."
|
|
564
564
|
}
|
|
565
565
|
config = config || basicQuery(this.datasource._id)
|
|
566
566
|
return this._req(config, null, controllers.query.save)
|