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

This commit is contained in:
mike12345567 2021-07-06 15:45:14 +01:00
parent 6648e548c5
commit ede0a5ec9b
2 changed files with 6 additions and 2 deletions

View File

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

View File

@ -147,7 +147,11 @@ module PostgresModule {
if (!tableKeys[tableName]) { if (!tableKeys[tableName]) {
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) { } catch (err) {
tableKeys = {} tableKeys = {}