@@ -4,6 +4,7 @@ import { MapperTable } from "../mapper-table";
44import { Column } from "./column" ;
55import { FieldType } from "./enums/field-type" ;
66import { ColumnsCompiled } from "./columns-compiled" ;
7+ import { PrimaryKeyType } from "./enums/primary-key-type" ;
78
89export abstract class ColumnsBaseBuilder <
910 TThis extends ColumnsBaseBuilder < TThis , T , TColumn > ,
@@ -28,28 +29,32 @@ export abstract class ColumnsBaseBuilder<
2829 public setColumn (
2930 column : string ,
3031 type : FieldType ,
31- isKeyColumn : boolean ,
32- isAutoIncrement : boolean
32+ primaryKeyType : PrimaryKeyType
33+ // isKeyColumn: boolean,
34+ // isAutoIncrement: boolean
3335 ) : TThis {
3436 this . columns . push ( {
3537 name : column ,
3638 type,
37- isKeyColumn,
38- isAutoIncrement
39+ primaryKeyType
40+ // isKeyColumn,
41+ // isAutoIncrement
3942 } as TColumn ) ;
4043 return this . getInstance ( ) ;
4144 }
4245
4346 public set < TReturn extends ValueTypeToParse > (
4447 expression : ExpressionOrColumn < TReturn , T > ,
45- isKeyColumn : boolean ,
46- isAutoIncrement : boolean
48+ primaryKeyType : PrimaryKeyType
49+ // isKeyColumn: boolean,
50+ // isAutoIncrement: boolean
4751 ) : TThis {
4852 return this . setColumn (
4953 Utils . getColumn ( expression ) ,
5054 Utils . getType ( this . metadata . instance , expression ) ,
51- isKeyColumn ,
52- isAutoIncrement
55+ primaryKeyType
56+ // isKeyColumn,
57+ // isAutoIncrement
5358 ) ;
5459 }
5560
@@ -62,7 +67,8 @@ export abstract class ColumnsBaseBuilder<
6267 for ( const key in this . columns ) {
6368 if ( this . columns . hasOwnProperty ( key ) ) {
6469 const column = this . columns [ key ] ;
65- if ( column . isKeyColumn ) {
70+ if ( column . primaryKeyType ) {
71+ // if (column.isKeyColumn) {
6672 result . keyColumns . push ( column . name ) ;
6773 }
6874 result . columns . push ( this . columnFormat ( column ) ) ;
@@ -72,7 +78,8 @@ export abstract class ColumnsBaseBuilder<
7278 }
7379
7480 protected isCompositeKey ( ) : boolean {
75- return this . metadata . mapperTable . columns . filter ( x => x . isKeyColumn === true ) . length > 1 ;
81+ return this . metadata . mapperTable . columns . filter ( x => ! ! x . primaryKeyType ) . length > 1 ;
82+ // return this.metadata.mapperTable.columns.filter(x => x.isKeyColumn === true).length > 1;
7683 }
7784
7885 protected abstract columnFormat ( column : TColumn ) : string ;
@@ -83,8 +90,9 @@ export abstract class ColumnsBaseBuilder<
8390 column : string ,
8491 value : ValueTypeToParse ,
8592 fieldType : FieldType ,
86- isKeyColumn : boolean ,
87- isAutoIncrement : boolean
93+ primaryKeyType : PrimaryKeyType
94+ // isKeyColumn: boolean,
95+ // isAutoIncrement: boolean
8896 ) : TThis ;
8997
9098 private setAllColumns ( mapper : MapperTable , modelWithValue : T ) : void {
@@ -95,8 +103,9 @@ export abstract class ColumnsBaseBuilder<
95103 column . column ,
96104 Utils . getValue ( modelWithValue , column . fieldReference ) ,
97105 column . fieldType ,
98- column . isKeyColumn ,
99- column . isAutoIncrement
106+ column . primaryKeyType
107+ // column.isKeyColumn,
108+ // column.isAutoIncrement
100109 ) ;
101110 }
102111 }
0 commit comments