@@ -421,7 +421,7 @@ export class DataAccessObjectClickHouse extends BasicDataAccessObject implements
421421 character_maximum_length : this . extractLength ( column . type ) ,
422422 data_type_params : this . extractTypeParams ( column . type ) ,
423423 udt_name : column . type ,
424- extra : column . is_in_primary_key ? 'primary_key' : undefined ,
424+ extra : this . buildExtraInfo ( column . is_in_primary_key , column . default_expression ) ,
425425 } ) ) ;
426426
427427 LRUStorage . setTableStructureCache ( this . connection , tableName , structure ) ;
@@ -795,6 +795,30 @@ export class DataAccessObjectClickHouse extends BasicDataAccessObject implements
795795 return null ;
796796 }
797797
798+ private buildExtraInfo ( isPrimaryKey : number , defaultExpression : string ) : string | undefined {
799+ const parts : string [ ] = [ ] ;
800+ if ( isPrimaryKey ) {
801+ parts . push ( 'primary_key' ) ;
802+ }
803+
804+ if ( defaultExpression ) {
805+ const lowerDefault = defaultExpression . toLowerCase ( ) ;
806+ if (
807+ lowerDefault . includes ( 'generateuuidv4' ) ||
808+ lowerDefault . includes ( 'generateuuid' ) ||
809+ lowerDefault . includes ( 'rownumberinallblocks' ) ||
810+ lowerDefault . includes ( 'rownumber' ) ||
811+ lowerDefault . includes ( 'auto_increment' ) ||
812+ lowerDefault . includes ( 'autoincrement' ) ||
813+ lowerDefault . includes ( 'nextval' ) ||
814+ lowerDefault . includes ( 'generate' )
815+ ) {
816+ parts . push ( 'auto_increment' ) ;
817+ }
818+ }
819+ return parts . length > 0 ? parts . join ( ' ' ) : undefined ;
820+ }
821+
798822 private async getRowsCount (
799823 client : ClickHouseClient ,
800824 tableName : string ,
0 commit comments