Merge pull request #2512 from Budibase/fix/martin-bugfixes-116

Fix/martin bugfixes 116
This commit is contained in:
Martin McKeaveney 2021-09-09 11:16:04 +01:00 committed by GitHub
commit 302f5c9e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1114 additions and 21 deletions

View File

@ -95,7 +95,7 @@
"lodash": "4.17.21", "lodash": "4.17.21",
"mongodb": "3.6.3", "mongodb": "3.6.3",
"mssql": "6.2.3", "mssql": "6.2.3",
"mysql": "2.18.1", "mysql": "^2.18.1",
"node-fetch": "2.6.0", "node-fetch": "2.6.0",
"open": "7.3.0", "open": "7.3.0",
"pg": "8.5.1", "pg": "8.5.1",

View File

@ -276,7 +276,7 @@ module External {
} }
outputProcessing( outputProcessing(
rows: Row[], rows: Row[] = [],
table: Table, table: Table,
relationships: RelationshipsJson[] relationships: RelationshipsJson[]
) { ) {

View File

@ -140,7 +140,7 @@ module MySQLModule {
this.client = mysql.createConnection(config) this.client = mysql.createConnection(config)
} }
async buildSchema(datasourceId: string) { async buildSchema(datasourceId: string, entities: Record<string, Table>) {
const tables: { [key: string]: Table } = {} const tables: { [key: string]: Table } = {}
const database = this.config.database const database = this.config.database
this.client.connect() this.client.connect()
@ -193,6 +193,19 @@ module MySQLModule {
schema, schema,
} }
} }
// add the existing relationships from the entities if they exist, to prevent them from being overridden
if (entities && entities[tableName]) {
const existingTableSchema = entities[tableName].schema
for (let key in existingTableSchema) {
if (!existingTableSchema.hasOwnProperty(key)) {
continue
}
if (existingTableSchema[key].type === "link") {
tables[tableName].schema[key] = existingTableSchema[key]
}
}
}
} }
this.client.end() this.client.end()

File diff suppressed because it is too large Load Diff