@budibase/server 0.9.190-alpha.0 → 0.9.190-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/builder/assets/{index.43f4c913.js → index.b5be8653.js} +127 -127
- package/builder/index.html +1 -1
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- 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/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query.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 +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.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/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.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/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.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 +1 -1
- 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/application.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/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.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/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/row.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/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- 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/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/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.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/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/automations/utils.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/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- 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 +1 -1
- 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/authorized.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/index.js.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/statusCodes.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/dist/api/controllers/row/ExternalRequest.js +41 -20
- package/dist/integrations/base/sql.js +29 -11
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/mysql.js +2 -1
- package/dist/integrations/oracle.js +5 -3
- package/dist/integrations/utils.js +1 -1
- package/dist/package.json +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/api/controllers/row/ExternalRequest.ts +44 -20
- package/src/integrations/base/sql.ts +30 -11
- package/src/integrations/index.ts +2 -2
- package/src/integrations/mysql.ts +3 -1
- package/src/integrations/oracle.ts +21 -8
- package/src/integrations/utils.ts +6 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "0.9.190-alpha.
|
|
4
|
+
"version": "0.9.190-alpha.1",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"author": "Budibase",
|
|
69
69
|
"license": "GPL-3.0",
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@budibase/auth": "^0.9.190-alpha.
|
|
72
|
-
"@budibase/client": "^0.9.190-alpha.
|
|
73
|
-
"@budibase/string-templates": "^0.9.190-alpha.
|
|
71
|
+
"@budibase/auth": "^0.9.190-alpha.1",
|
|
72
|
+
"@budibase/client": "^0.9.190-alpha.1",
|
|
73
|
+
"@budibase/string-templates": "^0.9.190-alpha.1",
|
|
74
74
|
"@bull-board/api": "^3.7.0",
|
|
75
75
|
"@bull-board/koa": "^3.7.0",
|
|
76
76
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -154,5 +154,5 @@
|
|
|
154
154
|
"optionalDependencies": {
|
|
155
155
|
"oracledb": "^5.3.0"
|
|
156
156
|
},
|
|
157
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "b585fe964293c4016848f850dd561982162e0896"
|
|
158
158
|
}
|
|
@@ -197,9 +197,9 @@ module External {
|
|
|
197
197
|
return row
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
function
|
|
200
|
+
function isOneSide(field: FieldSchema) {
|
|
201
201
|
return (
|
|
202
|
-
field.relationshipType && field.relationshipType.split("-")[0] === "
|
|
202
|
+
field.relationshipType && field.relationshipType.split("-")[0] === "one"
|
|
203
203
|
)
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -274,25 +274,37 @@ module External {
|
|
|
274
274
|
const linkTable = this.tables[linkTableName]
|
|
275
275
|
// @ts-ignore
|
|
276
276
|
const linkTablePrimary = linkTable.primary[0]
|
|
277
|
-
|
|
277
|
+
// one to many
|
|
278
|
+
if (isOneSide(field)) {
|
|
278
279
|
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(
|
|
279
280
|
row[key][0]
|
|
280
281
|
)[0]
|
|
281
|
-
}
|
|
282
|
+
}
|
|
283
|
+
// many to many
|
|
284
|
+
else if (field.through) {
|
|
282
285
|
// we're not inserting a doc, will be a bunch of update calls
|
|
283
|
-
const
|
|
284
|
-
const thisKey: string =
|
|
285
|
-
? "id"
|
|
286
|
-
: field.throughTo || linkTablePrimary
|
|
287
|
-
// @ts-ignore
|
|
288
|
-
const otherKey: string = isUpdate
|
|
289
|
-
? field.fieldName
|
|
290
|
-
: field.throughFrom || tablePrimary
|
|
286
|
+
const otherKey: string = field.throughFrom || linkTablePrimary
|
|
287
|
+
const thisKey: string = field.throughTo || tablePrimary
|
|
291
288
|
row[key].map((relationship: any) => {
|
|
292
|
-
// we don't really support composite keys for relationships, this is why [0] is used
|
|
293
289
|
manyRelationships.push({
|
|
294
290
|
tableId: field.through || field.tableId,
|
|
295
|
-
isUpdate,
|
|
291
|
+
isUpdate: false,
|
|
292
|
+
key: otherKey,
|
|
293
|
+
[otherKey]: breakRowIdField(relationship)[0],
|
|
294
|
+
// leave the ID for enrichment later
|
|
295
|
+
[thisKey]: `{{ literal ${tablePrimary} }}`,
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
// many to one
|
|
300
|
+
else {
|
|
301
|
+
const thisKey: string = "id"
|
|
302
|
+
// @ts-ignore
|
|
303
|
+
const otherKey: string = field.fieldName
|
|
304
|
+
row[key].map((relationship: any) => {
|
|
305
|
+
manyRelationships.push({
|
|
306
|
+
tableId: field.tableId,
|
|
307
|
+
isUpdate: true,
|
|
296
308
|
key: otherKey,
|
|
297
309
|
[thisKey]: breakRowIdField(relationship)[0],
|
|
298
310
|
// leave the ID for enrichment later
|
|
@@ -425,8 +437,8 @@ module External {
|
|
|
425
437
|
)
|
|
426
438
|
definition.through = throughTableName
|
|
427
439
|
// don't support composite keys for relationships
|
|
428
|
-
definition.from = field.
|
|
429
|
-
definition.to = field.
|
|
440
|
+
definition.from = field.throughTo || table.primary[0]
|
|
441
|
+
definition.to = field.throughFrom || linkTable.primary[0]
|
|
430
442
|
definition.fromPrimary = table.primary[0]
|
|
431
443
|
definition.toPrimary = linkTable.primary[0]
|
|
432
444
|
}
|
|
@@ -448,24 +460,36 @@ module External {
|
|
|
448
460
|
// make a new request to get the row with all its relationships
|
|
449
461
|
// we need this to work out if any relationships need removed
|
|
450
462
|
for (let field of Object.values(table.schema)) {
|
|
451
|
-
if (
|
|
463
|
+
if (
|
|
464
|
+
field.type !== FieldTypes.LINK ||
|
|
465
|
+
!field.fieldName ||
|
|
466
|
+
isOneSide(field)
|
|
467
|
+
) {
|
|
452
468
|
continue
|
|
453
469
|
}
|
|
454
470
|
const isMany = field.relationshipType === RelationshipTypes.MANY_TO_MANY
|
|
455
471
|
const tableId = isMany ? field.through : field.tableId
|
|
456
|
-
const
|
|
472
|
+
const { tableName: relatedTableName } = breakExternalTableId(tableId)
|
|
473
|
+
// @ts-ignore
|
|
474
|
+
const linkPrimaryKey = this.tables[relatedTableName].primary[0]
|
|
475
|
+
const manyKey = field.throughTo || primaryKey
|
|
476
|
+
const lookupField = isMany ? primaryKey : field.foreignKey
|
|
457
477
|
const fieldName = isMany ? manyKey : field.fieldName
|
|
478
|
+
if (!lookupField || !row[lookupField]) {
|
|
479
|
+
continue
|
|
480
|
+
}
|
|
458
481
|
const response = await getDatasourceAndQuery(this.appId, {
|
|
459
482
|
endpoint: getEndpoint(tableId, DataSourceOperation.READ),
|
|
460
483
|
filters: {
|
|
461
484
|
equal: {
|
|
462
|
-
[fieldName]: row[
|
|
485
|
+
[fieldName]: row[lookupField],
|
|
463
486
|
},
|
|
464
487
|
},
|
|
465
488
|
})
|
|
466
489
|
// this is the response from knex if no rows found
|
|
467
490
|
const rows = !response[0].read ? response : []
|
|
468
|
-
|
|
491
|
+
const storeTo = isMany ? field.throughFrom || linkPrimaryKey : manyKey
|
|
492
|
+
related[storeTo] = { rows, isMany, tableId }
|
|
469
493
|
}
|
|
470
494
|
return related
|
|
471
495
|
}
|
|
@@ -21,6 +21,9 @@ function parse(input: any) {
|
|
|
21
21
|
if (Array.isArray(input)) {
|
|
22
22
|
return JSON.stringify(input)
|
|
23
23
|
}
|
|
24
|
+
if (input == undefined) {
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
24
27
|
if (typeof input !== "string") {
|
|
25
28
|
return input
|
|
26
29
|
}
|
|
@@ -43,7 +46,10 @@ function parseBody(body: any) {
|
|
|
43
46
|
return body
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
function parseFilters(filters: SearchFilters): SearchFilters {
|
|
49
|
+
function parseFilters(filters: SearchFilters | undefined): SearchFilters {
|
|
50
|
+
if (!filters) {
|
|
51
|
+
return {}
|
|
52
|
+
}
|
|
47
53
|
for (let [key, value] of Object.entries(filters)) {
|
|
48
54
|
let parsed
|
|
49
55
|
if (typeof value === "object") {
|
|
@@ -152,6 +158,23 @@ class InternalBuilder {
|
|
|
152
158
|
return query
|
|
153
159
|
}
|
|
154
160
|
|
|
161
|
+
addSorting(query: KnexQuery, json: QueryJson): KnexQuery {
|
|
162
|
+
let { sort, paginate } = json
|
|
163
|
+
if (!sort) {
|
|
164
|
+
return query
|
|
165
|
+
}
|
|
166
|
+
const table = json.meta?.table
|
|
167
|
+
for (let [key, value] of Object.entries(sort)) {
|
|
168
|
+
const direction = value === SortDirection.ASCENDING ? "asc" : "desc"
|
|
169
|
+
query = query.orderBy(`${table?.name}.${key}`, direction)
|
|
170
|
+
}
|
|
171
|
+
if (this.client === SqlClients.MS_SQL && !sort && paginate?.limit) {
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
query = query.orderBy(`${table?.name}.${table?.primary[0]}`)
|
|
174
|
+
}
|
|
175
|
+
return query
|
|
176
|
+
}
|
|
177
|
+
|
|
155
178
|
addRelationships(
|
|
156
179
|
knex: Knex,
|
|
157
180
|
query: KnexQuery,
|
|
@@ -249,22 +272,18 @@ class InternalBuilder {
|
|
|
249
272
|
if (foundOffset) {
|
|
250
273
|
query = query.offset(foundOffset)
|
|
251
274
|
}
|
|
252
|
-
if (sort) {
|
|
253
|
-
for (let [key, value] of Object.entries(sort)) {
|
|
254
|
-
const direction = value === SortDirection.ASCENDING ? "asc" : "desc"
|
|
255
|
-
query = query.orderBy(key, direction)
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (this.client === SqlClients.MS_SQL && !sort && paginate?.limit) {
|
|
259
|
-
// @ts-ignore
|
|
260
|
-
query = query.orderBy(json.meta?.table?.primary[0])
|
|
261
|
-
}
|
|
262
275
|
query = this.addFilters(tableName, query, filters)
|
|
276
|
+
// add sorting to pre-query
|
|
277
|
+
query = this.addSorting(query, json)
|
|
263
278
|
// @ts-ignore
|
|
264
279
|
let preQuery: KnexQuery = knex({
|
|
265
280
|
// @ts-ignore
|
|
266
281
|
[tableName]: query,
|
|
267
282
|
}).select(selectStatement)
|
|
283
|
+
// have to add after as well (this breaks MS-SQL)
|
|
284
|
+
if (this.client !== SqlClients.MS_SQL) {
|
|
285
|
+
preQuery = this.addSorting(preQuery, json)
|
|
286
|
+
}
|
|
268
287
|
// handle joins
|
|
269
288
|
return this.addRelationships(
|
|
270
289
|
knex,
|
|
@@ -40,9 +40,9 @@ const INTEGRATIONS = {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// optionally add oracle integration if the oracle binary can be installed
|
|
43
|
-
if (!(process.arch ===
|
|
43
|
+
if (!(process.arch === "arm64" && process.platform === "darwin")) {
|
|
44
44
|
const oracle = require("./oracle")
|
|
45
|
-
DEFINITIONS[SourceNames.ORACLE] =
|
|
45
|
+
DEFINITIONS[SourceNames.ORACLE] = oracle.schema
|
|
46
46
|
INTEGRATIONS[SourceNames.ORACLE] = oracle.integration
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -134,7 +134,9 @@ module MySQLModule {
|
|
|
134
134
|
false
|
|
135
135
|
)
|
|
136
136
|
const tableNames = tablesResp.map(
|
|
137
|
-
(obj: any) =>
|
|
137
|
+
(obj: any) =>
|
|
138
|
+
obj[`Tables_in_${database}`] ||
|
|
139
|
+
obj[`Tables_in_${database.toLowerCase()}`]
|
|
138
140
|
)
|
|
139
141
|
for (let tableName of tableNames) {
|
|
140
142
|
const primaryKeys = []
|
|
@@ -352,14 +352,23 @@ module OracleModule {
|
|
|
352
352
|
* Knex default returning behaviour does not work with oracle
|
|
353
353
|
* Manually add the behaviour for the return column
|
|
354
354
|
*/
|
|
355
|
-
private addReturning(
|
|
355
|
+
private addReturning(
|
|
356
|
+
query: SqlQuery,
|
|
357
|
+
bindings: BindParameters,
|
|
358
|
+
returnColumn: string
|
|
359
|
+
) {
|
|
356
360
|
if (bindings instanceof Array) {
|
|
357
361
|
bindings.push({ dir: oracledb.BIND_OUT })
|
|
358
|
-
query.sql =
|
|
362
|
+
query.sql =
|
|
363
|
+
query.sql + ` returning \"${returnColumn}\" into :${bindings.length}`
|
|
359
364
|
}
|
|
360
365
|
}
|
|
361
366
|
|
|
362
|
-
private async internalQuery<T>(
|
|
367
|
+
private async internalQuery<T>(
|
|
368
|
+
query: SqlQuery,
|
|
369
|
+
returnColum?: string,
|
|
370
|
+
operation?: string
|
|
371
|
+
): Promise<Result<T>> {
|
|
363
372
|
let connection
|
|
364
373
|
try {
|
|
365
374
|
connection = await this.getConnection()
|
|
@@ -367,7 +376,10 @@ module OracleModule {
|
|
|
367
376
|
const options: ExecuteOptions = { autoCommit: true }
|
|
368
377
|
const bindings: BindParameters = query.bindings || []
|
|
369
378
|
|
|
370
|
-
if (
|
|
379
|
+
if (
|
|
380
|
+
returnColum &&
|
|
381
|
+
(operation === Operation.CREATE || operation === Operation.UPDATE)
|
|
382
|
+
) {
|
|
371
383
|
this.addReturning(query, bindings, returnColum)
|
|
372
384
|
}
|
|
373
385
|
|
|
@@ -414,14 +426,14 @@ module OracleModule {
|
|
|
414
426
|
return response.rows ? response.rows : []
|
|
415
427
|
}
|
|
416
428
|
|
|
417
|
-
async update(query: SqlQuery | string): Promise<any[]>
|
|
429
|
+
async update(query: SqlQuery | string): Promise<any[]> {
|
|
418
430
|
const response = await this.internalQuery(getSqlQuery(query))
|
|
419
431
|
return response.rows && response.rows.length
|
|
420
432
|
? response.rows
|
|
421
433
|
: [{ updated: true }]
|
|
422
434
|
}
|
|
423
435
|
|
|
424
|
-
async delete(query: SqlQuery | string): Promise<any[]>
|
|
436
|
+
async delete(query: SqlQuery | string): Promise<any[]> {
|
|
425
437
|
const response = await this.internalQuery(getSqlQuery(query))
|
|
426
438
|
return response.rows && response.rows.length
|
|
427
439
|
? response.rows
|
|
@@ -431,8 +443,9 @@ module OracleModule {
|
|
|
431
443
|
async query(json: QueryJson) {
|
|
432
444
|
const primaryKeys = json.meta!.table!.primary
|
|
433
445
|
const primaryKey = primaryKeys ? primaryKeys[0] : undefined
|
|
434
|
-
const queryFn = (query: any, operation: string) =>
|
|
435
|
-
|
|
446
|
+
const queryFn = (query: any, operation: string) =>
|
|
447
|
+
this.internalQuery(query, primaryKey, operation)
|
|
448
|
+
const processFn = (response: any) => (response.rows ? response.rows : [])
|
|
436
449
|
const output = await this.queryWithReturning(json, queryFn, processFn)
|
|
437
450
|
return output
|
|
438
451
|
}
|
|
@@ -2,7 +2,11 @@ import { SqlQuery } from "../definitions/datasource"
|
|
|
2
2
|
import { Datasource, Table } from "../definitions/common"
|
|
3
3
|
import { SourceNames } from "../definitions/datasource"
|
|
4
4
|
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
FieldTypes,
|
|
7
|
+
BuildSchemaErrors,
|
|
8
|
+
InvalidColumns,
|
|
9
|
+
} = require("../constants")
|
|
6
10
|
|
|
7
11
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
|
8
12
|
const ROW_ID_REGEX = /^\[.*]$/g
|
|
@@ -42,7 +46,7 @@ export enum SqlClients {
|
|
|
42
46
|
MS_SQL = "mssql",
|
|
43
47
|
POSTGRES = "pg",
|
|
44
48
|
MY_SQL = "mysql",
|
|
45
|
-
ORACLE = "oracledb"
|
|
49
|
+
ORACLE = "oracledb",
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
export function isExternalTable(tableId: string) {
|