@@ -28,11 +28,10 @@ final class ClickHousePlugin: NSObject, TableProPlugin, DriverPlugin {
2828private struct ClickHouseError : Error , PluginDriverError {
2929 let message : String
3030
31- var errorDescription : String ? { " ClickHouse Error: \( message) " }
3231 var pluginErrorMessage : String { message }
3332
34- static let notConnected = ClickHouseError ( message: " Not connected to database " )
35- static let connectionFailed = ClickHouseError ( message: " Failed to establish connection " )
33+ static let notConnected = ClickHouseError ( message: String ( localized : " Not connected to database " ) )
34+ static let connectionFailed = ClickHouseError ( message: String ( localized : " Failed to establish connection " ) )
3635}
3736
3837// MARK: - Internal Query Result
@@ -42,6 +41,7 @@ private struct CHQueryResult {
4241 let columnTypeNames : [ String ]
4342 let rows : [ [ String ? ] ]
4443 let affectedRows : Int
44+ let isTruncated : Bool
4545}
4646
4747// MARK: - Plugin Driver
@@ -139,7 +139,8 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
139139 columnTypeNames: result. columnTypeNames,
140140 rows: result. rows,
141141 rowsAffected: result. affectedRows,
142- executionTime: executionTime
142+ executionTime: executionTime,
143+ isTruncated: result. isTruncated
143144 )
144145 }
145146
@@ -159,7 +160,8 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
159160 columnTypeNames: result. columnTypeNames,
160161 rows: result. rows,
161162 rowsAffected: result. affectedRows,
162- executionTime: executionTime
163+ executionTime: executionTime,
164+ isTruncated: result. isTruncated
163165 )
164166 }
165167
@@ -584,7 +586,7 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
584586 return parseTabSeparatedResponse ( data)
585587 }
586588
587- return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 )
589+ return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 , isTruncated : false )
588590 }
589591
590592 private func executeRawWithParams( _ query: String , params: [ String : String ? ] , queryId: String ? = nil ) async throws -> CHQueryResult {
@@ -641,7 +643,7 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
641643 return parseTabSeparatedResponse ( data)
642644 }
643645
644- return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 )
646+ return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 , isTruncated : false )
645647 }
646648
647649 private func buildRequest( query: String , database: String , queryId: String ? = nil , params: [ String : String ? ] ? = nil ) throws -> URLRequest {
@@ -705,19 +707,20 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
705707
706708 private func parseTabSeparatedResponse( _ data: Data ) -> CHQueryResult {
707709 guard let text = String ( data: data, encoding: . utf8) , !text. isEmpty else {
708- return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 )
710+ return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 , isTruncated : false )
709711 }
710712
711713 let lines = text. components ( separatedBy: " \n " )
712714
713715 guard lines. count >= 2 else {
714- return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 )
716+ return CHQueryResult ( columns: [ ] , columnTypeNames: [ ] , rows: [ ] , affectedRows: 0 , isTruncated : false )
715717 }
716718
717719 let columns = lines [ 0 ] . components ( separatedBy: " \t " )
718720 let columnTypes = lines [ 1 ] . components ( separatedBy: " \t " )
719721
720722 var rows : [ [ String ? ] ] = [ ]
723+ var truncated = false
721724 for i in 2 ..< lines. count {
722725 let line = lines [ i]
723726 if line. isEmpty { continue }
@@ -731,6 +734,7 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
731734 }
732735 rows. append ( row)
733736 if rows. count >= PluginRowLimits . defaultMax {
737+ truncated = true
734738 break
735739 }
736740 }
@@ -739,7 +743,8 @@ final class ClickHousePluginDriver: PluginDatabaseDriver, @unchecked Sendable {
739743 columns: columns,
740744 columnTypeNames: columnTypes,
741745 rows: rows,
742- affectedRows: rows. count
746+ affectedRows: rows. count,
747+ isTruncated: truncated
743748 )
744749 }
745750
0 commit comments