Browse Source

Making sure that keys cannot be duplicated for primary keys, this wouldn't have any function.

master
mike12345567 5 years ago
parent
commit
ede0a5ec9b
  1. 2
      packages/server/src/integrations/mysql.ts
  2. 6
      packages/server/src/integrations/postgres.ts

2
packages/server/src/integrations/mysql.ts

@ -163,7 +163,7 @@ module MySQLModule {
)
for (let column of descResp) {
const columnName = column.Field
if (column.Key === "PRI") {
if (column.Key === "PRI" && primaryKeys.indexOf(column.Key) === -1) {
primaryKeys.push(columnName)
}
const constraints = {

6
packages/server/src/integrations/postgres.ts

@ -147,7 +147,11 @@ module PostgresModule {
if (!tableKeys[tableName]) {
tableKeys[tableName] = []
}
tableKeys[tableName].push(table.column_name || table.primary_key)
const key = table.column_name || table.primary_key
// only add the unique keys
if (key && tableKeys[tableName].indexOf(key) === -1) {
tableKeys[tableName].push(key)
}
}
} catch (err) {
tableKeys = {}

Loading…
Cancel
Save