Only get definition for given schema (#11532)
This commit is contained in:
parent
2557997db6
commit
6d40a54fd5
|
@ -8,7 +8,6 @@
|
|||
"name": "Budibase Server",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeVersion": "14.20.1",
|
||||
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
|
||||
"args": ["${workspaceFolder}/packages/server/src/index.ts"],
|
||||
"cwd": "${workspaceFolder}/packages/server"
|
||||
|
@ -17,7 +16,6 @@
|
|||
"name": "Budibase Worker",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeVersion": "14.20.1",
|
||||
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
|
||||
"args": ["${workspaceFolder}/packages/worker/src/index.ts"],
|
||||
"cwd": "${workspaceFolder}/packages/worker"
|
||||
|
|
|
@ -341,10 +341,10 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|||
}
|
||||
}
|
||||
|
||||
getDefinitionSQL(tableName: string) {
|
||||
getDefinitionSQL(tableName: string, schemaName: string) {
|
||||
return `select *
|
||||
from INFORMATION_SCHEMA.COLUMNS
|
||||
where TABLE_NAME='${tableName}'`
|
||||
where TABLE_NAME='${tableName}' AND TABLE_SCHEMA='${schemaName}'`
|
||||
}
|
||||
|
||||
getConstraintsSQL(tableName: string) {
|
||||
|
@ -388,16 +388,18 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|||
throw "Unable to get list of tables in database"
|
||||
}
|
||||
|
||||
const schema = this.config.schema || DEFAULT_SCHEMA
|
||||
const schemaName = this.config.schema || DEFAULT_SCHEMA
|
||||
const tableNames = tableInfo
|
||||
.filter((record: any) => record.TABLE_SCHEMA === schema)
|
||||
.filter((record: any) => record.TABLE_SCHEMA === schemaName)
|
||||
.map((record: any) => record.TABLE_NAME)
|
||||
.filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1)
|
||||
|
||||
const tables: Record<string, ExternalTable> = {}
|
||||
for (let tableName of tableNames) {
|
||||
// get the column definition (type)
|
||||
const definition = await this.runSQL(this.getDefinitionSQL(tableName))
|
||||
const definition = await this.runSQL(
|
||||
this.getDefinitionSQL(tableName, schemaName)
|
||||
)
|
||||
// find primary key constraints
|
||||
const constraints = await this.runSQL(this.getConstraintsSQL(tableName))
|
||||
// find the computed and identity columns (auto columns)
|
||||
|
|
Loading…
Reference in New Issue