diff --git a/main/DB/DBAppOnly.swift b/main/DB/DBAppOnly.swift index 0bb5edf..9443565 100644 --- a/main/DB/DBAppOnly.swift +++ b/main/DB/DBAppOnly.swift @@ -180,7 +180,7 @@ extension SQLiteDatabase { try? run(sql: "SELECT fqdn, ts FROM heap WHERE ts >= ? AND ts <= ? ORDER BY ts DESC, rowid ASC;", bind: [BindInt64(ts1), BindInt64(ts2)]) { allRows($0) { - (readText($0, 0) ?? "", col_ts($0, 1)) + (col_text($0, 0) ?? "", col_ts($0, 1)) } } } @@ -205,7 +205,7 @@ extension SQLiteDatabase { } return try? run(sql: "SELECT \(col), COUNT(*), COUNT(opt), MAX(ts) FROM heap \(Where) GROUP BY \(col);", bind: Where.bindings) { allRows($0) { - GroupedDomain(domain: readText($0, 0) ?? "", + GroupedDomain(domain: col_text($0, 0) ?? "", total: sqlite3_column_int($0, 1), blocked: sqlite3_column_int($0, 2), lastModified: col_ts($0, 3)) @@ -287,7 +287,7 @@ extension SQLiteDatabase { ) ORDER BY rank ASC LIMIT 99; """, bind: [BindInt64(dt), BindInt64(low), BindInt64(high), BindText(fqdn), BindInt64(dt)]) { allRows($0) { - (readText($0, 0) ?? "", sqlite3_column_int($0, 1), sqlite3_column_double($0, 2), sqlite3_column_double($0, 3)) + (col_text($0, 0) ?? "", sqlite3_column_int($0, 1), sqlite3_column_double($0, 2), sqlite3_column_double($0, 3)) } } } @@ -368,9 +368,9 @@ extension SQLiteDatabase { return Recording(id: sqlite3_column_int64(stmt, 0), start: col_ts(stmt, 1), stop: end == 0 ? nil : end, - appId: readText(stmt, 3), - title: readText(stmt, 4), - notes: readText(stmt, 5)) + appId: col_text(stmt, 3), + title: col_text(stmt, 4), + notes: col_text(stmt, 5)) } /// `WHERE stop IS NULL` @@ -448,7 +448,7 @@ extension SQLiteDatabase { func recordingLogsGetGrouped(_ r: Recording) -> [RecordLog]? { try? run(sql: "SELECT domain, COUNT() FROM recLog WHERE rid = ? GROUP BY domain;", bind: [BindInt64(r.id)]) { - allRows($0) { (readText($0, 0) ?? "", sqlite3_column_int($0, 1)) } + allRows($0) { (col_text($0, 0) ?? "", sqlite3_column_int($0, 1)) } } } } diff --git a/main/DB/DBCommon.swift b/main/DB/DBCommon.swift index 0bb9244..25e3b56 100644 --- a/main/DB/DBCommon.swift +++ b/main/DB/DBCommon.swift @@ -71,7 +71,7 @@ extension SQLiteDatabase { return try? run(sql: "SELECT domain, opt FROM filter \(rv>0 ? "WHERE opt & ?" : "");", bind: rv>0 ? [BindInt32(rv)] : []) { allRowsKeyed($0) { - (key: readText($0, 0) ?? "", + (key: col_text($0, 0) ?? "", value: FilterOptions(rawValue: sqlite3_column_int($0, 1))) } } diff --git a/main/DB/DBCore.swift b/main/DB/DBCore.swift index 7bd77ee..85a2d3e 100644 --- a/main/DB/DBCore.swift +++ b/main/DB/DBCore.swift @@ -193,7 +193,7 @@ extension SQLiteDatabase { var numberOfChanges: Int32 { get { sqlite3_changes(dbPointer) } } var lastInsertedRow: SQLiteRowID { get { sqlite3_last_insert_rowid(dbPointer) } } - func readText(_ stmt: OpaquePointer, _ col: Int32) -> String? { + func col_text(_ stmt: OpaquePointer, _ col: Int32) -> String? { let val = sqlite3_column_text(stmt, col) return (val != nil ? String(cString: val!) : nil) }