diff --git a/lib/active_record/connection_adapters/clickhouse_adapter.rb b/lib/active_record/connection_adapters/clickhouse_adapter.rb index 250f4b42..fd87e88a 100644 --- a/lib/active_record/connection_adapters/clickhouse_adapter.rb +++ b/lib/active_record/connection_adapters/clickhouse_adapter.rb @@ -279,6 +279,10 @@ def column_name_for_operation(operation, node) # :nodoc: def primary_keys(table_name) structure = do_system_execute("SHOW COLUMNS FROM `#{table_name}`") structure['data'].select {|m| m[3]&.include?('PRI') }.pluck(0) + rescue ActiveRecord::ActiveRecordError => e + pk = table_structure(table_name).first + return ['id'] if pk.present? && pk[0] == 'id' + [] end def create_schema_dumper(options) # :nodoc: