@budibase/server 1.3.19-alpha.1 → 1.3.19
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.9ce4f8c5.css +6 -0
- package/builder/assets/index.a1f7532b.js +876 -0
- package/builder/assets/vendor.5e1fe644.css +1 -0
- package/builder/assets/vendor.67dbd8fa.js +248 -0
- package/builder/index.html +4 -2
- package/coverage/clover.xml +388 -441
- package/coverage/coverage-final.json +20 -20
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +8 -41
- 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/component.js.html +11 -68
- package/coverage/lcov-report/api/controllers/datasource.js.html +34 -73
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +46 -46
- 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/screen.js.html +12 -207
- 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 +5 -5
- package/coverage/lcov-report/api/routes/utils/validators.js.html +6 -9
- 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 +18 -18
- 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 +20 -56
- 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 +37 -37
- 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 +40 -46
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov.info +667 -780
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +0 -9
- package/dist/api/controllers/component.js +1 -14
- package/dist/api/controllers/datasource.js +8 -21
- package/dist/api/controllers/deploy/index.js +8 -1
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +2 -52
- package/dist/api/controllers/static/index.js +0 -1
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/dist/api/controllers/static/templates/preview.hbs +1 -5
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +2 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +1 -2
- package/dist/app.js +0 -11
- package/dist/db/utils.js +1 -10
- package/dist/environment.js +0 -1
- package/dist/integrations/airtable.js +129 -126
- package/dist/integrations/arangodb.js +89 -86
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +1 -3
- package/dist/integrations/couchdb.js +83 -80
- package/dist/integrations/dynamodb.js +164 -161
- package/dist/integrations/elasticsearch.js +138 -135
- package/dist/integrations/firebase.js +157 -154
- package/dist/integrations/googlesheets.js +327 -323
- package/dist/integrations/index.js +51 -99
- package/dist/integrations/microsoftSqlServer.js +243 -240
- package/dist/integrations/mongodb.js +242 -239
- package/dist/integrations/mysql.js +219 -215
- package/dist/integrations/oracle.js +322 -318
- package/dist/integrations/postgres.js +265 -262
- package/dist/integrations/redis.js +139 -134
- package/dist/integrations/rest.js +292 -289
- package/dist/integrations/s3.js +64 -61
- package/dist/integrations/snowflake.js +86 -83
- package/dist/middleware/currentapp.js +0 -2
- package/dist/migrations/functions/backfill/global.js +3 -0
- package/dist/migrations/functions/developerQuota.js +49 -0
- package/dist/{api/routes/plugin.js → migrations/functions/publishedAppsQuota.js} +21 -13
- package/dist/{api/controllers/plugin/url.js → migrations/functions/usageQuotas/syncDevelopers.js} +13 -13
- package/dist/{api/controllers/plugin/file.js → migrations/functions/usageQuotas/syncPublishedApps.js} +15 -13
- package/dist/migrations/index.js +10 -0
- package/dist/package.json +6 -9
- 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 +1 -110
- package/package.json +7 -10
- package/scripts/dev/manage.js +0 -1
- package/scripts/localdomain.js +1 -3
- package/specs/openapi.json +3 -3
- package/specs/openapi.yaml +3 -3
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +2 -1
- package/src/api/controllers/auth.js +0 -11
- package/src/api/controllers/component.js +2 -21
- package/src/api/controllers/datasource.js +8 -21
- package/src/api/controllers/deploy/index.ts +6 -1
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.js +1 -66
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/src/api/controllers/static/templates/preview.hbs +1 -5
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +2 -13
- package/src/api/routes/index.ts +0 -2
- 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 +25 -8
- package/src/api/routes/tests/user.spec.js +2 -0
- package/src/api/routes/utils/validators.js +1 -2
- package/src/app.ts +0 -14
- package/src/db/utils.js +0 -12
- package/src/definitions/openapi.ts +3 -3
- package/src/environment.js +0 -1
- package/src/integrations/airtable.ts +118 -116
- package/src/integrations/arangodb.ts +89 -87
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +1 -3
- package/src/integrations/couchdb.ts +89 -83
- package/src/integrations/dynamodb.ts +175 -173
- package/src/integrations/elasticsearch.ts +122 -120
- package/src/integrations/firebase.ts +159 -157
- package/src/integrations/googlesheets.ts +338 -328
- package/src/integrations/index.ts +21 -64
- package/src/integrations/microsoftSqlServer.ts +251 -249
- package/src/integrations/mongodb.ts +258 -261
- package/src/integrations/mysql.ts +234 -229
- package/src/integrations/oracle.ts +380 -373
- package/src/integrations/postgres.ts +268 -264
- package/src/integrations/redis.ts +132 -128
- package/src/integrations/rest.ts +329 -324
- package/src/integrations/s3.ts +71 -68
- package/src/integrations/snowflake.ts +82 -80
- package/src/integrations/tests/{airtable.spec.ts → airtable.spec.js} +18 -21
- package/src/integrations/tests/{arangodb.spec.ts → arangodb.spec.js} +9 -12
- package/src/integrations/tests/{couchdb.spec.ts → couchdb.spec.js} +27 -33
- package/src/integrations/tests/{dynamodb.spec.ts → dynamodb.spec.js} +41 -45
- package/src/integrations/tests/{elasticsearch.spec.ts → elasticsearch.spec.js} +21 -22
- package/src/integrations/tests/{firebase.spec.ts → firebase.spec.js} +28 -33
- package/src/integrations/tests/{microsoftSqlServer.spec.ts → microsoftSqlServer.spec.js} +11 -12
- package/src/integrations/tests/{mongo.spec.ts → mongo.spec.js} +35 -46
- package/src/integrations/tests/{mysql.spec.ts → mysql.spec.js} +15 -17
- package/src/integrations/tests/{oracle.spec.ts → oracle.spec.js} +17 -19
- package/src/integrations/tests/{postgres.spec.ts → postgres.spec.js} +17 -19
- package/src/integrations/tests/{redis.spec.ts → redis.spec.js} +18 -27
- package/src/integrations/tests/{rest.spec.ts → rest.spec.js} +14 -22
- package/src/integrations/tests/{s3.spec.ts → s3.spec.js} +8 -10
- package/src/integrations/tests/{sql.spec.ts → sql.spec.js} +177 -228
- package/src/middleware/currentapp.js +0 -2
- package/src/migrations/functions/backfill/global.ts +3 -0
- package/src/migrations/functions/developerQuota.ts +15 -0
- package/src/migrations/functions/publishedAppsQuota.ts +13 -0
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +19 -0
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +21 -0
- package/src/migrations/index.ts +16 -0
- package/src/module.d.ts +0 -2
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +0 -129
- package/builder/assets/index.1709d1b3.js +0 -1005
- package/builder/assets/index.8f621053.css +0 -6
- package/dist/api/controllers/plugin/github.js +0 -69
- package/dist/api/controllers/plugin/index.js +0 -200
- package/dist/api/controllers/plugin/npm.js +0 -58
- package/dist/api/controllers/plugin/uploaders.js +0 -11
- package/dist/api/controllers/plugin/utils.js +0 -26
- package/dist/watch.js +0 -77
- package/dist/websocket.js +0 -22
- package/src/api/controllers/plugin/file.ts +0 -15
- package/src/api/controllers/plugin/github.ts +0 -75
- package/src/api/controllers/plugin/index.ts +0 -215
- package/src/api/controllers/plugin/npm.ts +0 -56
- package/src/api/controllers/plugin/uploaders.ts +0 -4
- package/src/api/controllers/plugin/url.ts +0 -12
- package/src/api/controllers/plugin/utils.ts +0 -19
- package/src/api/routes/plugin.ts +0 -14
- package/src/watch.ts +0 -38
- package/src/websocket.ts +0 -26
|
@@ -3,7 +3,7 @@ const { SqlClient } = require("../utils")
|
|
|
3
3
|
|
|
4
4
|
const TABLE_NAME = "test"
|
|
5
5
|
|
|
6
|
-
function endpoint(table
|
|
6
|
+
function endpoint(table, operation) {
|
|
7
7
|
return {
|
|
8
8
|
datasourceId: "Postgres",
|
|
9
9
|
operation: operation,
|
|
@@ -11,13 +11,7 @@ function endpoint(table: any, operation: any) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function generateReadJson({
|
|
15
|
-
table,
|
|
16
|
-
fields,
|
|
17
|
-
filters,
|
|
18
|
-
sort,
|
|
19
|
-
paginate,
|
|
20
|
-
}: any = {}) {
|
|
14
|
+
function generateReadJson({ table, fields, filters, sort, paginate} = {}) {
|
|
21
15
|
return {
|
|
22
16
|
endpoint: endpoint(table || TABLE_NAME, "READ"),
|
|
23
17
|
resource: {
|
|
@@ -54,7 +48,7 @@ function generateDeleteJson(table = TABLE_NAME, filters = {}) {
|
|
|
54
48
|
describe("SQL query builder", () => {
|
|
55
49
|
const limit = 500
|
|
56
50
|
const client = SqlClient.POSTGRES
|
|
57
|
-
let sql
|
|
51
|
+
let sql
|
|
58
52
|
|
|
59
53
|
beforeEach(() => {
|
|
60
54
|
sql = new Sql(client, limit)
|
|
@@ -64,139 +58,118 @@ describe("SQL query builder", () => {
|
|
|
64
58
|
const query = sql._query(generateReadJson())
|
|
65
59
|
expect(query).toEqual({
|
|
66
60
|
bindings: [limit],
|
|
67
|
-
sql: `select * from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"
|
|
61
|
+
sql: `select * from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"`
|
|
68
62
|
})
|
|
69
63
|
})
|
|
70
64
|
|
|
71
65
|
it("should test a read with specific columns", () => {
|
|
72
|
-
const nameProp = `${TABLE_NAME}.name`,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
fields: [nameProp, ageProp],
|
|
77
|
-
})
|
|
78
|
-
)
|
|
66
|
+
const nameProp = `${TABLE_NAME}.name`, ageProp = `${TABLE_NAME}.age`
|
|
67
|
+
const query = sql._query(generateReadJson({
|
|
68
|
+
fields: [nameProp, ageProp]
|
|
69
|
+
}))
|
|
79
70
|
expect(query).toEqual({
|
|
80
71
|
bindings: [limit],
|
|
81
|
-
sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"
|
|
72
|
+
sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"`
|
|
82
73
|
})
|
|
83
74
|
})
|
|
84
75
|
|
|
85
76
|
it("should test a where string starts with read", () => {
|
|
86
|
-
const query = sql._query(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
)
|
|
77
|
+
const query = sql._query(generateReadJson({
|
|
78
|
+
filters: {
|
|
79
|
+
string: {
|
|
80
|
+
name: "John",
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}))
|
|
95
84
|
expect(query).toEqual({
|
|
96
85
|
bindings: ["John%", limit],
|
|
97
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2) as "${TABLE_NAME}"
|
|
86
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2) as "${TABLE_NAME}"`
|
|
98
87
|
})
|
|
99
88
|
})
|
|
100
89
|
|
|
101
90
|
it("should test a where range read", () => {
|
|
102
|
-
const query = sql._query(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
})
|
|
113
|
-
)
|
|
91
|
+
const query = sql._query(generateReadJson({
|
|
92
|
+
filters: {
|
|
93
|
+
range: {
|
|
94
|
+
age: {
|
|
95
|
+
low: 2,
|
|
96
|
+
high: 10,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}))
|
|
114
101
|
expect(query).toEqual({
|
|
115
102
|
bindings: [2, 10, limit],
|
|
116
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" between $1 and $2 limit $3) as "${TABLE_NAME}"
|
|
103
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" between $1 and $2 limit $3) as "${TABLE_NAME}"`
|
|
117
104
|
})
|
|
118
105
|
})
|
|
119
106
|
|
|
120
107
|
it("should test for multiple IDs with OR", () => {
|
|
121
|
-
const query = sql._query(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
name: "John",
|
|
127
|
-
},
|
|
128
|
-
allOr: true,
|
|
108
|
+
const query = sql._query(generateReadJson({
|
|
109
|
+
filters: {
|
|
110
|
+
equal: {
|
|
111
|
+
age: 10,
|
|
112
|
+
name: "John",
|
|
129
113
|
},
|
|
130
|
-
|
|
131
|
-
|
|
114
|
+
allOr: true,
|
|
115
|
+
}
|
|
116
|
+
}))
|
|
132
117
|
expect(query).toEqual({
|
|
133
118
|
bindings: [10, "John", limit],
|
|
134
|
-
sql: `select * from (select * from "${TABLE_NAME}" where ("${TABLE_NAME}"."age" = $1) or ("${TABLE_NAME}"."name" = $2) limit $3) as "${TABLE_NAME}"
|
|
119
|
+
sql: `select * from (select * from "${TABLE_NAME}" where ("${TABLE_NAME}"."age" = $1) or ("${TABLE_NAME}"."name" = $2) limit $3) as "${TABLE_NAME}"`
|
|
135
120
|
})
|
|
136
121
|
})
|
|
137
122
|
|
|
138
123
|
it("should allow filtering on a related field", () => {
|
|
139
|
-
const query = sql._query(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"task.name": "task 1",
|
|
145
|
-
},
|
|
124
|
+
const query = sql._query(generateReadJson({
|
|
125
|
+
filters: {
|
|
126
|
+
equal: {
|
|
127
|
+
age: 10,
|
|
128
|
+
"task.name": "task 1",
|
|
146
129
|
},
|
|
147
|
-
}
|
|
148
|
-
)
|
|
130
|
+
},
|
|
131
|
+
}))
|
|
149
132
|
// order of bindings changes because relationship filters occur outside inner query
|
|
150
133
|
expect(query).toEqual({
|
|
151
134
|
bindings: [10, limit, "task 1"],
|
|
152
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3
|
|
135
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3`
|
|
153
136
|
})
|
|
154
137
|
})
|
|
155
138
|
|
|
156
139
|
it("should test an create statement", () => {
|
|
157
|
-
const query = sql._query(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
})
|
|
162
|
-
)
|
|
140
|
+
const query = sql._query(generateCreateJson(TABLE_NAME, {
|
|
141
|
+
name: "Michael",
|
|
142
|
+
age: 45,
|
|
143
|
+
}))
|
|
163
144
|
expect(query).toEqual({
|
|
164
145
|
bindings: [45, "Michael"],
|
|
165
|
-
sql: `insert into "${TABLE_NAME}" ("age", "name") values ($1, $2) returning
|
|
146
|
+
sql: `insert into "${TABLE_NAME}" ("age", "name") values ($1, $2) returning *`
|
|
166
147
|
})
|
|
167
148
|
})
|
|
168
149
|
|
|
169
150
|
it("should test an update statement", () => {
|
|
170
|
-
const query = sql._query(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
equal: {
|
|
178
|
-
id: 1001,
|
|
179
|
-
},
|
|
180
|
-
}
|
|
181
|
-
)
|
|
182
|
-
)
|
|
151
|
+
const query = sql._query(generateUpdateJson(TABLE_NAME, {
|
|
152
|
+
name: "John"
|
|
153
|
+
}, {
|
|
154
|
+
equal: {
|
|
155
|
+
id: 1001,
|
|
156
|
+
}
|
|
157
|
+
}))
|
|
183
158
|
expect(query).toEqual({
|
|
184
159
|
bindings: ["John", 1001],
|
|
185
|
-
sql: `update "${TABLE_NAME}" set "name" = $1 where "${TABLE_NAME}"."id" = $2 returning
|
|
160
|
+
sql: `update "${TABLE_NAME}" set "name" = $1 where "${TABLE_NAME}"."id" = $2 returning *`
|
|
186
161
|
})
|
|
187
162
|
})
|
|
188
163
|
|
|
189
164
|
it("should test a delete statement", () => {
|
|
190
|
-
const query = sql._query(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
})
|
|
196
|
-
)
|
|
165
|
+
const query = sql._query(generateDeleteJson(TABLE_NAME, {
|
|
166
|
+
equal: {
|
|
167
|
+
id: 1001,
|
|
168
|
+
}
|
|
169
|
+
}))
|
|
197
170
|
expect(query).toEqual({
|
|
198
171
|
bindings: [1001],
|
|
199
|
-
sql: `delete from "${TABLE_NAME}" where "${TABLE_NAME}"."id" = $1 returning
|
|
172
|
+
sql: `delete from "${TABLE_NAME}" where "${TABLE_NAME}"."id" = $1 returning *`
|
|
200
173
|
})
|
|
201
174
|
})
|
|
202
175
|
|
|
@@ -204,7 +177,7 @@ describe("SQL query builder", () => {
|
|
|
204
177
|
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson())
|
|
205
178
|
expect(query).toEqual({
|
|
206
179
|
bindings: [10],
|
|
207
|
-
sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]
|
|
180
|
+
sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]`
|
|
208
181
|
})
|
|
209
182
|
})
|
|
210
183
|
|
|
@@ -212,217 +185,193 @@ describe("SQL query builder", () => {
|
|
|
212
185
|
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson())
|
|
213
186
|
expect(query).toEqual({
|
|
214
187
|
bindings: [10],
|
|
215
|
-
sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}
|
|
188
|
+
sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\``
|
|
216
189
|
})
|
|
217
190
|
})
|
|
218
191
|
|
|
219
192
|
it("should use greater than when only low range specified", () => {
|
|
220
193
|
const date = new Date()
|
|
221
|
-
const query = sql._query(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
})
|
|
231
|
-
)
|
|
194
|
+
const query = sql._query(generateReadJson({
|
|
195
|
+
filters: {
|
|
196
|
+
range: {
|
|
197
|
+
property: {
|
|
198
|
+
low: date,
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}))
|
|
232
203
|
expect(query).toEqual({
|
|
233
204
|
bindings: [date, limit],
|
|
234
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"
|
|
205
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`
|
|
235
206
|
})
|
|
236
207
|
})
|
|
237
208
|
|
|
238
209
|
it("should use less than when only high range specified", () => {
|
|
239
210
|
const date = new Date()
|
|
240
|
-
const query = sql._query(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
})
|
|
250
|
-
)
|
|
211
|
+
const query = sql._query(generateReadJson({
|
|
212
|
+
filters: {
|
|
213
|
+
range: {
|
|
214
|
+
property: {
|
|
215
|
+
high: date,
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}))
|
|
251
220
|
expect(query).toEqual({
|
|
252
221
|
bindings: [date, limit],
|
|
253
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" < $1 limit $2) as "${TABLE_NAME}"
|
|
222
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" < $1 limit $2) as "${TABLE_NAME}"`
|
|
254
223
|
})
|
|
255
224
|
})
|
|
256
225
|
|
|
257
226
|
it("should use greater than when only low range specified", () => {
|
|
258
227
|
const date = new Date()
|
|
259
|
-
const query = sql._query(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
})
|
|
269
|
-
)
|
|
228
|
+
const query = sql._query(generateReadJson({
|
|
229
|
+
filters: {
|
|
230
|
+
range: {
|
|
231
|
+
property: {
|
|
232
|
+
low: date,
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}))
|
|
270
237
|
expect(query).toEqual({
|
|
271
238
|
bindings: [date, limit],
|
|
272
|
-
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"
|
|
239
|
+
sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`
|
|
273
240
|
})
|
|
274
241
|
})
|
|
275
242
|
|
|
276
243
|
it("should use AND like expression for MS-SQL when filter is contains", () => {
|
|
277
|
-
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
})
|
|
286
|
-
)
|
|
244
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({
|
|
245
|
+
filters: {
|
|
246
|
+
contains: {
|
|
247
|
+
age: [20, 25],
|
|
248
|
+
name: ["John", "Mary"]
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}))
|
|
287
252
|
expect(query).toEqual({
|
|
288
253
|
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`],
|
|
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}]
|
|
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}]`
|
|
290
255
|
})
|
|
291
256
|
})
|
|
292
257
|
|
|
293
258
|
it("should use JSON_CONTAINS expression for MySQL when filter is contains", () => {
|
|
294
|
-
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
})
|
|
303
|
-
)
|
|
259
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({
|
|
260
|
+
filters: {
|
|
261
|
+
contains: {
|
|
262
|
+
age: [20],
|
|
263
|
+
name: ["John"]
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}))
|
|
304
267
|
expect(query).toEqual({
|
|
305
268
|
bindings: [10],
|
|
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}
|
|
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}\``
|
|
307
270
|
})
|
|
308
271
|
})
|
|
309
272
|
|
|
310
273
|
it("should use jsonb operator expression for PostgreSQL when filter is contains", () => {
|
|
311
|
-
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
})
|
|
320
|
-
)
|
|
274
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({
|
|
275
|
+
filters: {
|
|
276
|
+
contains: {
|
|
277
|
+
age: [20],
|
|
278
|
+
name: ["John"]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}))
|
|
321
282
|
expect(query).toEqual({
|
|
322
283
|
bindings: [10],
|
|
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}\"
|
|
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}\"`
|
|
324
285
|
})
|
|
325
286
|
})
|
|
326
287
|
|
|
327
288
|
it("should use NOT like expression for MS-SQL when filter is notContains", () => {
|
|
328
|
-
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
})
|
|
337
|
-
)
|
|
289
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({
|
|
290
|
+
filters: {
|
|
291
|
+
notContains: {
|
|
292
|
+
age: [20],
|
|
293
|
+
name: ["John"]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}))
|
|
338
297
|
expect(query).toEqual({
|
|
339
298
|
bindings: [10, "%20%", `%"John"%`],
|
|
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}]
|
|
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}]`
|
|
341
300
|
})
|
|
342
301
|
})
|
|
343
302
|
|
|
344
303
|
it("should use NOT JSON_CONTAINS expression for MySQL when filter is notContains", () => {
|
|
345
|
-
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
})
|
|
354
|
-
)
|
|
304
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({
|
|
305
|
+
filters: {
|
|
306
|
+
notContains: {
|
|
307
|
+
age: [20],
|
|
308
|
+
name: ["John"]
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}))
|
|
355
312
|
expect(query).toEqual({
|
|
356
313
|
bindings: [10],
|
|
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}
|
|
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}\``
|
|
358
315
|
})
|
|
359
316
|
})
|
|
360
317
|
|
|
361
318
|
it("should use jsonb operator NOT expression for PostgreSQL when filter is notContains", () => {
|
|
362
|
-
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
})
|
|
371
|
-
)
|
|
319
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({
|
|
320
|
+
filters: {
|
|
321
|
+
notContains: {
|
|
322
|
+
age: [20],
|
|
323
|
+
name: ["John"]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}))
|
|
372
327
|
expect(query).toEqual({
|
|
373
328
|
bindings: [10],
|
|
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}\"
|
|
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}\"`
|
|
375
330
|
})
|
|
376
331
|
})
|
|
377
332
|
|
|
378
333
|
it("should use OR like expression for MS-SQL when filter is containsAny", () => {
|
|
379
|
-
const query = new Sql(SqlClient.MS_SQL, 10)._query(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
})
|
|
388
|
-
)
|
|
334
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({
|
|
335
|
+
filters: {
|
|
336
|
+
containsAny: {
|
|
337
|
+
age: [20, 25],
|
|
338
|
+
name: ["John", "Mary"]
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}))
|
|
389
342
|
expect(query).toEqual({
|
|
390
343
|
bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`],
|
|
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}]
|
|
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}]`
|
|
392
345
|
})
|
|
393
346
|
})
|
|
394
347
|
|
|
395
348
|
it("should use JSON_OVERLAPS expression for MySQL when filter is containsAny", () => {
|
|
396
|
-
const query = new Sql(SqlClient.MY_SQL, 10)._query(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
})
|
|
405
|
-
)
|
|
349
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({
|
|
350
|
+
filters: {
|
|
351
|
+
containsAny: {
|
|
352
|
+
age: [20, 25],
|
|
353
|
+
name: ["John", "Mary"]
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}))
|
|
406
357
|
expect(query).toEqual({
|
|
407
358
|
bindings: [10],
|
|
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}
|
|
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}\``
|
|
409
360
|
})
|
|
410
361
|
})
|
|
411
362
|
|
|
412
363
|
it("should use ?| operator expression for PostgreSQL when filter is containsAny", () => {
|
|
413
|
-
const query = new Sql(SqlClient.POSTGRES, 10)._query(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
})
|
|
422
|
-
)
|
|
364
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({
|
|
365
|
+
filters: {
|
|
366
|
+
containsAny: {
|
|
367
|
+
age: [20, 25],
|
|
368
|
+
name: ["John", "Mary"]
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}))
|
|
423
372
|
expect(query).toEqual({
|
|
424
373
|
bindings: [10],
|
|
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}\"
|
|
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}\"`
|
|
426
375
|
})
|
|
427
376
|
})
|
|
428
377
|
})
|
|
@@ -111,14 +111,12 @@ 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
|
|
115
114
|
const userId = ctx.user ? generateUserMetadataID(ctx.user._id) : null
|
|
116
115
|
ctx.user = {
|
|
117
116
|
...ctx.user,
|
|
118
117
|
// override userID with metadata one
|
|
119
118
|
_id: userId,
|
|
120
119
|
userId,
|
|
121
|
-
globalId,
|
|
122
120
|
roleId,
|
|
123
121
|
role: await getRole(roleId),
|
|
124
122
|
}
|
|
@@ -35,10 +35,12 @@ const formatUsage = (usage: QuotaUsage) => {
|
|
|
35
35
|
let maxAutomations = 0
|
|
36
36
|
let maxQueries = 0
|
|
37
37
|
let rows = 0
|
|
38
|
+
let developers = 0
|
|
38
39
|
|
|
39
40
|
if (usage) {
|
|
40
41
|
if (usage.usageQuota) {
|
|
41
42
|
rows = usage.usageQuota.rows
|
|
43
|
+
developers = usage.usageQuota.developers
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
if (usage.monthly) {
|
|
@@ -57,6 +59,7 @@ const formatUsage = (usage: QuotaUsage) => {
|
|
|
57
59
|
maxAutomations,
|
|
58
60
|
maxQueries,
|
|
59
61
|
rows,
|
|
62
|
+
developers,
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { createUserBuildersView } = require("@budibase/backend-core/db")
|
|
2
|
+
import * as syncDevelopers from "./usageQuotas/syncDevelopers"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Date:
|
|
6
|
+
* March 2022
|
|
7
|
+
*
|
|
8
|
+
* Description:
|
|
9
|
+
* Create the builder users view and sync the developer count
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const run = async (db: any) => {
|
|
13
|
+
await createUserBuildersView(db)
|
|
14
|
+
await syncDevelopers.run()
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getTenantId } from "@budibase/backend-core/tenancy"
|
|
2
|
+
import { utils } from "@budibase/backend-core"
|
|
3
|
+
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
|
|
4
|
+
|
|
5
|
+
export const run = async () => {
|
|
6
|
+
// get developer count
|
|
7
|
+
const developerCount = await utils.getBuildersCount()
|
|
8
|
+
|
|
9
|
+
// sync developer count
|
|
10
|
+
const tenantId = getTenantId()
|
|
11
|
+
console.log(
|
|
12
|
+
`[Tenant: ${tenantId}] Syncing developer count: ${developerCount}`
|
|
13
|
+
)
|
|
14
|
+
await quotas.setUsage(
|
|
15
|
+
developerCount,
|
|
16
|
+
StaticQuotaName.DEVELOPERS,
|
|
17
|
+
QuotaUsageType.STATIC
|
|
18
|
+
)
|
|
19
|
+
}
|