Merge pull request #291 from seamuncle/master
Makes Postgres driver aware of new identity columns
This commit is contained in:
commit
71a64a7403
@ -372,7 +372,7 @@ export default abstract class AbstractDriver {
|
||||
);
|
||||
|
||||
let fieldType = "";
|
||||
if (isOneToMany) {
|
||||
if (ownerRelation.relationType === "OneToMany") {
|
||||
fieldType = `${ownerColumns[0].tscType}[]`;
|
||||
} else {
|
||||
fieldType = ownerColumns[0].tscType;
|
||||
|
@ -73,7 +73,8 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
character_maximum_length: number;
|
||||
numeric_precision: number;
|
||||
numeric_scale: number;
|
||||
isidentity: string;
|
||||
isidentity: string; // SERIAL identity type
|
||||
is_identity: string; // reccommended INDENTITY type for pg > 10
|
||||
isunique: string;
|
||||
enumvalues: string | null;
|
||||
/* eslint-enable camelcase */
|
||||
@ -82,6 +83,7 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
.query(`SELECT table_name,column_name,udt_name,column_default,is_nullable,
|
||||
data_type,character_maximum_length,numeric_precision,numeric_scale,
|
||||
case when column_default LIKE 'nextval%' then 'YES' else 'NO' end isidentity,
|
||||
is_identity,
|
||||
(SELECT count(*)
|
||||
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
|
||||
inner join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE cu
|
||||
@ -114,7 +116,9 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
if (resp.isunique === "1") options.unique = true;
|
||||
|
||||
const generated =
|
||||
resp.isidentity === "YES" ? true : undefined;
|
||||
resp.isidentity === "YES" || resp.is_identity === "YES"
|
||||
? true
|
||||
: undefined;
|
||||
const defaultValue = generated
|
||||
? undefined
|
||||
: PostgresDriver.ReturnDefaultValueFunction(
|
||||
|
@ -26,5 +26,5 @@ export class PostReader {
|
||||
post: Post;
|
||||
|
||||
@RelationId((postReader: PostReader) => postReader.post)
|
||||
postId: number[];
|
||||
postId: number;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user