@budibase/server 1.0.80-alpha.0 → 1.0.80-alpha.3
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.b37e0ebb.js → index.f8c92447.js} +2 -2
- 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/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/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/index.js.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 +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/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 +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/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/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/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/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/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.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/threads/utils.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/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.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/dist/integrations/base/sql.js +16 -1
- package/dist/integrations/base/sqlTable.js +8 -4
- package/dist/integrations/microsoftSqlServer.js +28 -17
- package/dist/integrations/utils.js +32 -15
- package/dist/package.json +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/scripts/integrations/mssql/data/setup.sql +18 -1
- package/scripts/integrations/postgres/init.sql +6 -0
- package/specs/generate.js +13 -2
- package/specs/openapi.json +13 -3
- package/specs/openapi.yaml +10 -2
- package/src/definitions/datasource.ts +1 -0
- package/src/integrations/base/sql.ts +16 -1
- package/src/integrations/base/sqlTable.ts +11 -7
- package/src/integrations/microsoftSqlServer.ts +52 -32
- package/src/integrations/utils.ts +43 -15
|
@@ -289,7 +289,7 @@ exports.getUniqueRows = async appIds => {
|
|
|
289
289
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
290
290
|
Code coverage generated by
|
|
291
291
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
292
|
-
at
|
|
292
|
+
at Mon Mar 07 2022 17:22:13 GMT+0000 (Coordinated Universal Time)
|
|
293
293
|
</div>
|
|
294
294
|
</div>
|
|
295
295
|
<script src="../../prettify.js"></script>
|
|
@@ -118,7 +118,7 @@ function <span class="fstat-no" title="function not covered" >resetQuotasIfRequi
|
|
|
118
118
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
119
119
|
Code coverage generated by
|
|
120
120
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
121
|
-
at
|
|
121
|
+
at Mon Mar 07 2022 17:22:13 GMT+0000 (Coordinated Universal Time)
|
|
122
122
|
</div>
|
|
123
123
|
</div>
|
|
124
124
|
<script src="../../prettify.js"></script>
|
|
@@ -136,7 +136,7 @@ exports.getFullUser = async (ctx, userId) => {
|
|
|
136
136
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
137
137
|
Code coverage generated by
|
|
138
138
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
139
|
-
at
|
|
139
|
+
at Mon Mar 07 2022 17:22:13 GMT+0000 (Coordinated Universal Time)
|
|
140
140
|
</div>
|
|
141
141
|
</div>
|
|
142
142
|
<script src="../prettify.js"></script>
|
|
@@ -481,7 +481,7 @@ exports.readGlobalUser = <span class="fstat-no" title="function not covered" >as
|
|
|
481
481
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
482
482
|
Code coverage generated by
|
|
483
483
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
484
|
-
at
|
|
484
|
+
at Mon Mar 07 2022 17:22:13 GMT+0000 (Coordinated Universal Time)
|
|
485
485
|
</div>
|
|
486
486
|
</div>
|
|
487
487
|
<script src="../prettify.js"></script>
|
|
@@ -232,6 +232,9 @@ class InternalBuilder {
|
|
|
232
232
|
create(knex, json, opts) {
|
|
233
233
|
const { endpoint, body } = json;
|
|
234
234
|
let query = knex(endpoint.entityId);
|
|
235
|
+
if (endpoint.schema) {
|
|
236
|
+
query = query.withSchema(endpoint.schema);
|
|
237
|
+
}
|
|
235
238
|
const parsedBody = parseBody(body);
|
|
236
239
|
// make sure no null values in body for creation
|
|
237
240
|
for (let [key, value] of Object.entries(parsedBody)) {
|
|
@@ -250,6 +253,9 @@ class InternalBuilder {
|
|
|
250
253
|
bulkCreate(knex, json) {
|
|
251
254
|
const { endpoint, body } = json;
|
|
252
255
|
let query = knex(endpoint.entityId);
|
|
256
|
+
if (endpoint.schema) {
|
|
257
|
+
query = query.withSchema(endpoint.schema);
|
|
258
|
+
}
|
|
253
259
|
if (!Array.isArray(body)) {
|
|
254
260
|
return query;
|
|
255
261
|
}
|
|
@@ -257,7 +263,7 @@ class InternalBuilder {
|
|
|
257
263
|
return query.insert(parsedBody);
|
|
258
264
|
}
|
|
259
265
|
read(knex, json, limit) {
|
|
260
|
-
let { endpoint, resource, filters,
|
|
266
|
+
let { endpoint, resource, filters, paginate, relationships } = json;
|
|
261
267
|
const tableName = endpoint.entityId;
|
|
262
268
|
// select all if not specified
|
|
263
269
|
if (!resource) {
|
|
@@ -285,6 +291,9 @@ class InternalBuilder {
|
|
|
285
291
|
}
|
|
286
292
|
// start building the query
|
|
287
293
|
let query = knex(tableName).limit(foundLimit);
|
|
294
|
+
if (endpoint.schema) {
|
|
295
|
+
query = query.withSchema(endpoint.schema);
|
|
296
|
+
}
|
|
288
297
|
if (foundOffset) {
|
|
289
298
|
query = query.offset(foundOffset);
|
|
290
299
|
}
|
|
@@ -307,6 +316,9 @@ class InternalBuilder {
|
|
|
307
316
|
update(knex, json, opts) {
|
|
308
317
|
const { endpoint, body, filters } = json;
|
|
309
318
|
let query = knex(endpoint.entityId);
|
|
319
|
+
if (endpoint.schema) {
|
|
320
|
+
query = query.withSchema(endpoint.schema);
|
|
321
|
+
}
|
|
310
322
|
const parsedBody = parseBody(body);
|
|
311
323
|
query = this.addFilters(query, filters, { tableName: endpoint.entityId });
|
|
312
324
|
// mysql can't use returning
|
|
@@ -320,6 +332,9 @@ class InternalBuilder {
|
|
|
320
332
|
delete(knex, json, opts) {
|
|
321
333
|
const { endpoint, filters } = json;
|
|
322
334
|
let query = knex(endpoint.entityId);
|
|
335
|
+
if (endpoint.schema) {
|
|
336
|
+
query = query.withSchema(endpoint.schema);
|
|
337
|
+
}
|
|
323
338
|
query = this.addFilters(query, filters, { tableName: endpoint.entityId });
|
|
324
339
|
// mysql can't use returning
|
|
325
340
|
if (opts.disableReturning) {
|
|
@@ -87,17 +87,17 @@ function generateSchema(schema, table, tables, oldTable = null) {
|
|
|
87
87
|
return schema;
|
|
88
88
|
}
|
|
89
89
|
function buildCreateTable(knex, table, tables) {
|
|
90
|
-
return knex.
|
|
90
|
+
return knex.createTable(table.name, schema => {
|
|
91
91
|
generateSchema(schema, table, tables);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
function buildUpdateTable(knex, table, tables, oldTable) {
|
|
95
|
-
return knex.
|
|
95
|
+
return knex.alterTable(table.name, schema => {
|
|
96
96
|
generateSchema(schema, table, tables, oldTable);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
function buildDeleteTable(knex, table) {
|
|
100
|
-
return knex.
|
|
100
|
+
return knex.dropTable(table.name);
|
|
101
101
|
}
|
|
102
102
|
class SqlTableQueryBuilder {
|
|
103
103
|
// pass through client to get flavour of SQL
|
|
@@ -115,7 +115,11 @@ class SqlTableQueryBuilder {
|
|
|
115
115
|
return json.endpoint.operation;
|
|
116
116
|
}
|
|
117
117
|
_tableQuery(json) {
|
|
118
|
-
|
|
118
|
+
var _a;
|
|
119
|
+
let client = knex_1.knex({ client: this.sqlClient }).schema;
|
|
120
|
+
if ((_a = json === null || json === void 0 ? void 0 : json.endpoint) === null || _a === void 0 ? void 0 : _a.schema) {
|
|
121
|
+
client = client.withSchema(json.endpoint.schema);
|
|
122
|
+
}
|
|
119
123
|
let query;
|
|
120
124
|
if (!json.table || !json.meta || !json.meta.tables) {
|
|
121
125
|
throw "Cannot execute without table being specified";
|
|
@@ -15,6 +15,7 @@ var MSSQLModule;
|
|
|
15
15
|
(function (MSSQLModule) {
|
|
16
16
|
const sqlServer = require("mssql");
|
|
17
17
|
const Sql = require("./base/sql");
|
|
18
|
+
const DEFAULT_SCHEMA = "dbo";
|
|
18
19
|
const SCHEMA = {
|
|
19
20
|
docs: "https://github.com/tediousjs/node-mssql",
|
|
20
21
|
plus: true,
|
|
@@ -43,6 +44,10 @@ var MSSQLModule;
|
|
|
43
44
|
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
44
45
|
default: "root",
|
|
45
46
|
},
|
|
47
|
+
schema: {
|
|
48
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
49
|
+
default: DEFAULT_SCHEMA,
|
|
50
|
+
},
|
|
46
51
|
encrypt: {
|
|
47
52
|
type: datasource_1.DatasourceFieldTypes.BOOLEAN,
|
|
48
53
|
default: true,
|
|
@@ -87,6 +92,20 @@ var MSSQLModule;
|
|
|
87
92
|
this.pool = new sqlServer.ConnectionPool(clientCfg);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
95
|
+
getBindingIdentifier() {
|
|
96
|
+
return `(@p${this.index++})`;
|
|
97
|
+
}
|
|
98
|
+
connect() {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
try {
|
|
101
|
+
this.client = yield this.pool.connect();
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
throw new Error(err);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
90
109
|
internalQuery(query, operation = undefined) {
|
|
91
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
111
|
const client = this.client;
|
|
@@ -137,20 +156,6 @@ var MSSQLModule;
|
|
|
137
156
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
138
157
|
WHERE TABLE_NAME='${tableName}'`;
|
|
139
158
|
}
|
|
140
|
-
getBindingIdentifier() {
|
|
141
|
-
return `(@p${this.index++})`;
|
|
142
|
-
}
|
|
143
|
-
connect() {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
try {
|
|
146
|
-
this.client = yield this.pool.connect();
|
|
147
|
-
}
|
|
148
|
-
catch (err) {
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
throw new Error(err);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
159
|
runSQL(sql) {
|
|
155
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
161
|
return (yield this.internalQuery(utils_1.getSqlQuery(sql))).recordset;
|
|
@@ -164,11 +169,13 @@ var MSSQLModule;
|
|
|
164
169
|
buildSchema(datasourceId, entities) {
|
|
165
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
171
|
yield this.connect();
|
|
167
|
-
let
|
|
168
|
-
if (
|
|
172
|
+
let tableInfo = yield this.runSQL(this.TABLES_SQL);
|
|
173
|
+
if (tableInfo == null || !Array.isArray(tableInfo)) {
|
|
169
174
|
throw "Unable to get list of tables in database";
|
|
170
175
|
}
|
|
171
|
-
|
|
176
|
+
const schema = this.config.schema || DEFAULT_SCHEMA;
|
|
177
|
+
const tableNames = tableInfo
|
|
178
|
+
.filter((record) => record.TABLE_SCHEMA === schema)
|
|
172
179
|
.map((record) => record.TABLE_NAME)
|
|
173
180
|
.filter((name) => this.MASTER_TABLES.indexOf(name) === -1);
|
|
174
181
|
const tables = {};
|
|
@@ -240,7 +247,11 @@ var MSSQLModule;
|
|
|
240
247
|
}
|
|
241
248
|
query(json) {
|
|
242
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
const schema = this.config.schema;
|
|
243
251
|
yield this.connect();
|
|
252
|
+
if (schema && schema !== DEFAULT_SCHEMA && (json === null || json === void 0 ? void 0 : json.endpoint)) {
|
|
253
|
+
json.endpoint.schema = schema;
|
|
254
|
+
}
|
|
244
255
|
const operation = this._operation(json);
|
|
245
256
|
const queryFn = (query, op) => this.internalQuery(query, op);
|
|
246
257
|
const processFn = (result) => result.recordset ? result.recordset : [{ [operation]: true }];
|
|
@@ -6,36 +6,53 @@ const utils_1 = require("../db/utils");
|
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const DOUBLE_SEPARATOR = `${utils_1.SEPARATOR}${utils_1.SEPARATOR}`;
|
|
8
8
|
const ROW_ID_REGEX = /^\[.*]$/g;
|
|
9
|
-
const
|
|
10
|
-
text: constants_1.FieldTypes.LONGFORM,
|
|
11
|
-
varchar: constants_1.FieldTypes.STRING,
|
|
9
|
+
const SQL_NUMBER_TYPE_MAP = {
|
|
12
10
|
integer: constants_1.FieldTypes.NUMBER,
|
|
11
|
+
int: constants_1.FieldTypes.NUMBER,
|
|
13
12
|
bigint: constants_1.FieldTypes.NUMBER,
|
|
14
13
|
decimal: constants_1.FieldTypes.NUMBER,
|
|
15
14
|
smallint: constants_1.FieldTypes.NUMBER,
|
|
16
15
|
real: constants_1.FieldTypes.NUMBER,
|
|
17
|
-
"double precision": constants_1.FieldTypes.NUMBER,
|
|
18
|
-
timestamp: constants_1.FieldTypes.DATETIME,
|
|
19
|
-
time: constants_1.FieldTypes.DATETIME,
|
|
20
|
-
boolean: constants_1.FieldTypes.BOOLEAN,
|
|
21
|
-
json: constants_1.FieldTypes.JSON,
|
|
22
|
-
date: constants_1.FieldTypes.DATETIME,
|
|
23
|
-
blob: constants_1.FieldTypes.LONGFORM,
|
|
24
|
-
enum: constants_1.FieldTypes.STRING,
|
|
25
16
|
float: constants_1.FieldTypes.NUMBER,
|
|
26
|
-
int: constants_1.FieldTypes.NUMBER,
|
|
27
17
|
numeric: constants_1.FieldTypes.NUMBER,
|
|
28
18
|
mediumint: constants_1.FieldTypes.NUMBER,
|
|
29
19
|
dec: constants_1.FieldTypes.NUMBER,
|
|
30
20
|
double: constants_1.FieldTypes.NUMBER,
|
|
31
21
|
fixed: constants_1.FieldTypes.NUMBER,
|
|
32
|
-
|
|
33
|
-
tinyint: constants_1.FieldTypes.BOOLEAN,
|
|
34
|
-
long: constants_1.FieldTypes.LONGFORM,
|
|
22
|
+
"double precision": constants_1.FieldTypes.NUMBER,
|
|
35
23
|
number: constants_1.FieldTypes.NUMBER,
|
|
36
24
|
binary_float: constants_1.FieldTypes.NUMBER,
|
|
37
25
|
binary_double: constants_1.FieldTypes.NUMBER,
|
|
26
|
+
money: constants_1.FieldTypes.NUMBER,
|
|
27
|
+
smallmoney: constants_1.FieldTypes.NUMBER,
|
|
28
|
+
};
|
|
29
|
+
const SQL_DATE_TYPE_MAP = {
|
|
30
|
+
timestamp: constants_1.FieldTypes.DATETIME,
|
|
31
|
+
time: constants_1.FieldTypes.DATETIME,
|
|
32
|
+
datetime: constants_1.FieldTypes.DATETIME,
|
|
33
|
+
smalldatetime: constants_1.FieldTypes.DATETIME,
|
|
34
|
+
date: constants_1.FieldTypes.DATETIME,
|
|
35
|
+
};
|
|
36
|
+
const SQL_STRING_TYPE_MAP = {
|
|
37
|
+
varchar: constants_1.FieldTypes.STRING,
|
|
38
|
+
char: constants_1.FieldTypes.STRING,
|
|
39
|
+
nchar: constants_1.FieldTypes.STRING,
|
|
40
|
+
nvarchar: constants_1.FieldTypes.STRING,
|
|
41
|
+
ntext: constants_1.FieldTypes.STRING,
|
|
42
|
+
enum: constants_1.FieldTypes.STRING,
|
|
43
|
+
blob: constants_1.FieldTypes.LONGFORM,
|
|
44
|
+
long: constants_1.FieldTypes.LONGFORM,
|
|
45
|
+
text: constants_1.FieldTypes.LONGFORM,
|
|
46
|
+
};
|
|
47
|
+
const SQL_BOOLEAN_TYPE_MAP = {
|
|
48
|
+
boolean: constants_1.FieldTypes.BOOLEAN,
|
|
49
|
+
bit: constants_1.FieldTypes.BOOLEAN,
|
|
50
|
+
tinyint: constants_1.FieldTypes.BOOLEAN,
|
|
51
|
+
};
|
|
52
|
+
const SQL_MISC_TYPE_MAP = {
|
|
53
|
+
json: constants_1.FieldTypes.JSON,
|
|
38
54
|
};
|
|
55
|
+
const SQL_TYPE_MAP = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, SQL_NUMBER_TYPE_MAP), SQL_DATE_TYPE_MAP), SQL_STRING_TYPE_MAP), SQL_BOOLEAN_TYPE_MAP), SQL_MISC_TYPE_MAP);
|
|
39
56
|
var SqlClients;
|
|
40
57
|
(function (SqlClients) {
|
|
41
58
|
SqlClients["MS_SQL"] = "mssql";
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.80-alpha.2",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"license": "GPL-3.0",
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
74
|
-
"@budibase/backend-core": "^1.0.
|
|
75
|
-
"@budibase/client": "^1.0.
|
|
76
|
-
"@budibase/string-templates": "^1.0.
|
|
74
|
+
"@budibase/backend-core": "^1.0.80-alpha.2",
|
|
75
|
+
"@budibase/client": "^1.0.80-alpha.2",
|
|
76
|
+
"@budibase/string-templates": "^1.0.80-alpha.2",
|
|
77
77
|
"@bull-board/api": "^3.7.0",
|
|
78
78
|
"@bull-board/koa": "^3.7.0",
|
|
79
79
|
"@elastic/elasticsearch": "7.10.0",
|