Merge pull request #291 from seamuncle/master

Makes Postgres driver aware of new identity columns
This commit is contained in:
Paweł Kotarski 2020-08-22 18:48:34 +02:00 committed by GitHub
commit 71a64a7403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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(

View File

@ -26,5 +26,5 @@ export class PostReader {
post: Post;
@RelationId((postReader: PostReader) => postReader.post)
postId: number[];
postId: number;
}