Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export class DataAccessObjectClickHouse extends BasicDataAccessObject implements
character_maximum_length: this.extractLength(column.type),
data_type_params: this.extractTypeParams(column.type),
udt_name: column.type,
extra: column.is_in_primary_key ? 'primary_key' : undefined,
extra: this.buildExtraInfo(column.is_in_primary_key, column.default_expression),
}));

LRUStorage.setTableStructureCache(this.connection, tableName, structure);
Expand Down Expand Up @@ -795,6 +795,30 @@ export class DataAccessObjectClickHouse extends BasicDataAccessObject implements
return null;
}

private buildExtraInfo(isPrimaryKey: number, defaultExpression: string): string | undefined {
const parts: string[] = [];
if (isPrimaryKey) {
parts.push('primary_key');
}

if (defaultExpression) {
const lowerDefault = defaultExpression.toLowerCase();
if (
lowerDefault.includes('generateuuidv4') ||
lowerDefault.includes('generateuuid') ||
lowerDefault.includes('rownumberinallblocks') ||
lowerDefault.includes('rownumber') ||
lowerDefault.includes('auto_increment') ||
lowerDefault.includes('autoincrement') ||
lowerDefault.includes('nextval') ||
lowerDefault.includes('generate')
Comment on lines +813 to +814
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition lowerDefault.includes('generate') is too broad and will incorrectly flag many default expressions that aren't auto-increment related. For example, it would match expressions like "regenerate_token()", "generate_report()", or any string containing the word "generate". This could lead to false positives where columns are incorrectly marked as having auto_increment behavior.

Consider either removing this catch-all condition or making it more specific to ClickHouse auto-generation functions. The more specific checks above it (generateuuidv4, generateuuid, etc.) should be sufficient for most cases.

Suggested change
lowerDefault.includes('nextval') ||
lowerDefault.includes('generate')
lowerDefault.includes('nextval')

Copilot uses AI. Check for mistakes.
) {
parts.push('auto_increment');
}
}
return parts.length > 0 ? parts.join(' ') : undefined;
}

private async getRowsCount(
client: ClickHouseClient,
tableName: string,
Expand Down
Loading