Skip to content

Commit

Permalink
Update oracledb.ts (directus#5331)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aidenfoxx authored Apr 28, 2021
1 parent a4e2c49 commit da826e2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/schema/src/dialects/oracledb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down

0 comments on commit da826e2

Please sign in to comment.