Update oracledb.ts (#5331)

As explained in the code comment, Oracle doesn't return "AUTO_INCREMENT", causing `authorization.ts` to throw a error that primary keys are required values.
This commit is contained in:
Aiden Foxx
2021-04-28 20:07:15 +02:00
committed by GitHub
parent a4e2c499e8
commit da826e2a1a

View File

@@ -60,10 +60,18 @@ export default class Oracle extends KnexOracle implements SchemaInspector {
columns: {},
};
}
/**
* Oracle doesn't return AUTO_INCREMENT. Incrementing is done using triggers, and there is no
* nice way to detect if a trigger is an increment trigger. For compatibility sake, assume all
* numeric primary keys AUTO_INCREMENT to prevent authorization throwing a "required value" error.
*/
const isNumericPrimary = column.data_type === 'NUMBER' && overview[column.table_name].primary;
overview[column.table_name].columns[column.column_name] = {
...column,
is_nullable: column.is_nullable === 'Y',
default_value: !column.default_value && isNumericPrimary ? 'AUTO_INCREMENT' : column.default_value,
};
}