Skip to content

Commit

Permalink
Fix Expression symbol, warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
christophhagen committed Jan 31, 2025
1 parent 676d72d commit b02391d
Show file tree
Hide file tree
Showing 30 changed files with 148 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension HKWorkoutActivity {
}
}

extension HKWorkoutActivity: Comparable {
extension HKWorkoutActivity: @retroactive Comparable {

public static func < (lhs: HKWorkoutActivity, rhs: HKWorkoutActivity) -> Bool {
lhs.startDate < rhs.startDate
Expand Down
2 changes: 1 addition & 1 deletion Sources/HealthDB/Support/HKBiologicalSex+Description.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKBiologicalSex: CustomStringConvertible {
extension HKBiologicalSex: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down
2 changes: 1 addition & 1 deletion Sources/HealthDB/Support/HKBloodType+Description.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKBloodType: CustomStringConvertible {
extension HKBloodType: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKFitzpatrickSkinType: CustomStringConvertible {
extension HKFitzpatrickSkinType: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKWorkoutActivityType: CustomStringConvertible {
extension HKWorkoutActivityType: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down Expand Up @@ -179,7 +179,7 @@ extension HKWorkoutActivityType: CustomStringConvertible {
}
}

extension HKWorkoutActivityType: Comparable {
extension HKWorkoutActivityType: @retroactive Comparable {

public static func < (lhs: HKWorkoutActivityType, rhs: HKWorkoutActivityType) -> Bool {
lhs.rawValue < rhs.rawValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKWorkoutEventType: CustomStringConvertible {
extension HKWorkoutEventType: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKWorkoutSessionLocationType: CustomStringConvertible {
extension HKWorkoutSessionLocationType: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import HealthKit

extension HKWorkoutSwimmingLocationType: CustomStringConvertible {
extension HKWorkoutSwimmingLocationType: @retroactive CustomStringConvertible {

public var description: String {
switch self {
Expand Down
9 changes: 4 additions & 5 deletions Sources/HealthDB/Tables/AssociationsTable.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Foundation
import SQLite

struct AssociationsTable {

let table = Table("associations")

let parentId = Expression<Int>("parent_id")
let parentId = SQLite.Expression<Int>("parent_id")

let childId = Expression<Int>("child_id")
let childId = SQLite.Expression<Int>("child_id")

let syncProvenance = Expression<Int>("sync_provenance")
let syncProvenance = SQLite.Expression<Int>("sync_provenance")

let syncIdentity = Expression<Int>("sync_identity")
let syncIdentity = SQLite.Expression<Int>("sync_identity")

func create(in database: Connection) throws {
try database.run("CREATE TABLE associations (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, child_id INTEGER, sync_provenance INTEGER, sync_identity INTEGER NOT NULL, UNIQUE(parent_id, child_id))")
Expand Down
4 changes: 2 additions & 2 deletions Sources/HealthDB/Tables/BinarySamplesTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ struct BinarySamplesTable {
try database.execute("CREATE TABLE binary_samples (data_id INTEGER PRIMARY KEY REFERENCES samples (data_id) ON DELETE CASCADE, payload BLOB)")
}

let dataId = Expression<Int>("data_id")
let dataId = SQLite.Expression<Int>("data_id")

let payload = Expression<Data?>("payload")
let payload = SQLite.Expression<Data?>("payload")

func payload(for dataId: Int, in database: Connection) throws -> Data? {
try database.pluck(table.filter(self.dataId == dataId)).map { $0[payload] }
Expand Down
5 changes: 2 additions & 3 deletions Sources/HealthDB/Tables/CategorySamplesTable.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Foundation
import SQLite

struct CategorySamplesTable {
Expand All @@ -9,9 +8,9 @@ struct CategorySamplesTable {
try database.execute("CREATE TABLE category_samples (data_id INTEGER PRIMARY KEY, value INTEGER)")
}

let dataId = Expression<Int>("data_id")
let dataId = SQLite.Expression<Int>("data_id")

let value = Expression<Int?>("value")
let value = SQLite.Expression<Int?>("value")

func value(for dataId: Int, in database: Connection) throws -> Int? {
try database.pluck(table.filter(self.dataId == dataId)).map { $0[value] }
Expand Down
33 changes: 16 additions & 17 deletions Sources/HealthDB/Tables/DataProvenancesTable.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Foundation
import SQLite
import HealthKit

Expand All @@ -10,39 +9,39 @@ struct DataProvenancesTable {

let table = Table("data_provenances")

let rowId = Expression<Int>("ROWID")
let rowId = SQLite.Expression<Int>("ROWID")

let syncProvenance = Expression<Int>("sync_provenance")
let syncProvenance = SQLite.Expression<Int>("sync_provenance")

/// Device that created the data (e.g. Watch)
let originProductType = Expression<String>("origin_product_type")
let originProductType = SQLite.Expression<String>("origin_product_type")

let originBuild = Expression<String>("origin_build")
let originBuild = SQLite.Expression<String>("origin_build")

/// Device saving the data (e.g. iPhone)
let localProductType = Expression<String>("local_product_type")
let localProductType = SQLite.Expression<String>("local_product_type")

let localBuild = Expression<String>("local_build")
let localBuild = SQLite.Expression<String>("local_build")

let sourceId = Expression<Int>("source_id")
let sourceId = SQLite.Expression<Int>("source_id")

let deviceId = Expression<Int>("device_id")
let deviceId = SQLite.Expression<Int>("device_id")

let contributorId = Expression<Int>("contributor_id")
let contributorId = SQLite.Expression<Int>("contributor_id")

let sourceVersion = Expression<String>("source_version")
let sourceVersion = SQLite.Expression<String>("source_version")

let tzName = Expression<String>("tz_name")
let tzName = SQLite.Expression<String>("tz_name")

let originMajorVersion = Expression<Int>("origin_major_version")
let originMajorVersion = SQLite.Expression<Int>("origin_major_version")

let originMinorVersion = Expression<Int>("origin_minor_version")
let originMinorVersion = SQLite.Expression<Int>("origin_minor_version")

let originPatchVersion = Expression<Int>("origin_patch_version")
let originPatchVersion = SQLite.Expression<Int>("origin_patch_version")

let syncIdentity = Expression<Int>("sync_identity")
let syncIdentity = SQLite.Expression<Int>("sync_identity")

let derivedFlags = Expression<Int>("derived_flags")
let derivedFlags = SQLite.Expression<Int>("derived_flags")

func device(for rowId: Int, in database: Connection) throws -> HKDevice? {
try database.pluck(table.filter(self.rowId == rowId)).map { row in
Expand Down
13 changes: 6 additions & 7 deletions Sources/HealthDB/Tables/DataSeriesTable.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Foundation
import SQLite

struct DataSeriesTable {
Expand All @@ -9,15 +8,15 @@ struct DataSeriesTable {
try database.execute("CREATE TABLE data_series (data_id INTEGER PRIMARY KEY REFERENCES samples(data_id) ON DELETE CASCADE, frozen INTEGER NOT NULL DEFAULT 0, count INTEGER NOT NULL DEFAULT 0, insertion_era INTEGER NOT NULL DEFAULT 0, hfd_key INTEGER UNIQUE NOT NULL, series_location INTEGER NOT NULL)")
}

let dataId = Expression<Int>("data_id")
let dataId = SQLite.Expression<Int>("data_id")

let frozen = Expression<Int>("frozen")
let frozen = SQLite.Expression<Int>("frozen")

let count = Expression<Int>("count")
let count = SQLite.Expression<Int>("count")

let insertionEra = Expression<Int>("insertion_era")
let insertionEra = SQLite.Expression<Int>("insertion_era")

let hfdKey = Expression<Int>("hfd_key")
let hfdKey = SQLite.Expression<Int>("hfd_key")

let seriesLocation = Expression<Int>("series_location")
let seriesLocation = SQLite.Expression<Int>("series_location")
}
10 changes: 5 additions & 5 deletions Sources/HealthDB/Tables/ECGSamplesTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ struct ECGSamplesTable {
try database.execute("CREATE TABLE ecg_samples (data_id INTEGER PRIMARY KEY REFERENCES samples (data_id) ON DELETE CASCADE, private_classification INTEGER NOT NULL, average_heart_rate REAL, voltage_payload BLOB NOT NULL, symptoms_status INTEGER NOT NULL)")
}

let dataId = Expression<Int>("data_id")
let dataId = SQLite.Expression<Int>("data_id")

let privateClassification = Expression<Int>("private_classification")
let privateClassification = SQLite.Expression<Int>("private_classification")

let averageHeartRate = Expression<Double?>("average_heart_rate")
let averageHeartRate = SQLite.Expression<Double?>("average_heart_rate")

let voltagePayload = Expression<Data>("voltage_payload")
let voltagePayload = SQLite.Expression<Data>("voltage_payload")

let symptomsStatus = Expression<Int>("symptoms_status")
let symptomsStatus = SQLite.Expression<Int>("symptoms_status")

func payload(for dataId: Int, in database: Connection) throws -> ECGVoltageData? {
try database.pluck(table.filter(self.dataId == dataId))
Expand Down
16 changes: 8 additions & 8 deletions Sources/HealthDB/Tables/KeyValueSecureTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ struct KeyValueSecureTable {
try database.execute("CREATE TABLE key_value_secure (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, category INTEGER NOT NULL, domain TEXT NOT NULL, key TEXT NOT NULL, value, provenance INTEGER NOT NULL, mod_date REAL NOT NULL, sync_identity INTEGER NOT NULL, UNIQUE(category, domain, key))")
}

let category = Expression<Int>("category")
let category = SQLite.Expression<Int>("category")

let domain = Expression<String>("domain")
let domain = SQLite.Expression<String>("domain")

let key = Expression<String>("key")
let key = SQLite.Expression<String>("key")

let dataValue = Expression<Data?>("value")
let intValue = Expression<Int?>("value")
let dataValue = SQLite.Expression<Data?>("value")
let intValue = SQLite.Expression<Int?>("value")

let provenance = Expression<Int>("provenance")
let provenance = SQLite.Expression<Int>("provenance")

let modificationDate = Expression<Double>("mod_date")
let modificationDate = SQLite.Expression<Double>("mod_date")

let syncIdentity = Expression<Int>("sync_identity")
let syncIdentity = SQLite.Expression<Int>("sync_identity")

func value<T>(for key: String, in database: Connection) throws -> T? where T: Value {
try database.pluck(table.filter(self.key == key)).map {
Expand Down
24 changes: 12 additions & 12 deletions Sources/HealthDB/Tables/LocationSeriesDataTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ struct LocationSeriesDataTable {
let table = Table("location_series_data")

/// `location_series_data[series_identifier]` <-> `workout_activities[ROW_ID]`
let seriesIdentifier = Expression<Int>("series_identifier")
let seriesIdentifier = SQLite.Expression<Int>("series_identifier")

let timestamp = Expression<Double>("timestamp")
let timestamp = SQLite.Expression<Double>("timestamp")

let longitude = Expression<Double>("longitude")
let longitude = SQLite.Expression<Double>("longitude")

let latitude = Expression<Double>("latitude")
let latitude = SQLite.Expression<Double>("latitude")

let altitude = Expression<Double>("altitude")
let altitude = SQLite.Expression<Double>("altitude")

let speed = Expression<Double>("speed")
let speed = SQLite.Expression<Double>("speed")

let course = Expression<Double>("course")
let course = SQLite.Expression<Double>("course")

let horizontalAccuracy = Expression<Double>("horizontal_accuracy")
let horizontalAccuracy = SQLite.Expression<Double>("horizontal_accuracy")

let verticalAccuracy = Expression<Double>("vertical_accuracy")
let verticalAccuracy = SQLite.Expression<Double>("vertical_accuracy")

let speedAccuracy = Expression<Double>("speed_accuracy")
let speedAccuracy = SQLite.Expression<Double>("speed_accuracy")

let courseAccuracy = Expression<Double>("course_accuracy")
let courseAccuracy = SQLite.Expression<Double>("course_accuracy")

let signalEnvironment = Expression<Double>("signal_environment")
let signalEnvironment = SQLite.Expression<Double>("signal_environment")

func locations(for seriesId: Int, in database: Connection) throws -> [CLLocation] {
let query = table.filter(seriesIdentifier == seriesId)
Expand Down
5 changes: 2 additions & 3 deletions Sources/HealthDB/Tables/MetadataKeysTable.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Foundation
import SQLite

struct MetadataKeysTable {

let table = Table("metadata_keys")

let rowId = Expression<Int>("ROWID")
let rowId = SQLite.Expression<Int>("ROWID")

let key = Expression<String>("key")
let key = SQLite.Expression<String>("key")

func create(in database: Connection) throws {
//try database.execute("CREATE TABLE metadata_keys (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT UNIQUE)")
Expand Down
17 changes: 8 additions & 9 deletions Sources/HealthDB/Tables/MetadataValuesTable.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import Foundation
import SQLite
import HealthKit

struct MetadataValuesTable {

let table = Table("metadata_values")

let rowId = Expression<Int>("ROW_ID")
let rowId = SQLite.Expression<Int>("ROW_ID")

let keyId = Expression<Int?>("key_id")
let keyId = SQLite.Expression<Int?>("key_id")

let objectId = Expression<Int?>("object_id")
let objectId = SQLite.Expression<Int?>("object_id")

let valueType = Expression<Int>("value_type")
let valueType = SQLite.Expression<Int>("value_type")

let stringValue = Expression<String?>("string_value")
let stringValue = SQLite.Expression<String?>("string_value")

let numericalValue = Expression<Double?>("numerical_value")
let numericalValue = SQLite.Expression<Double?>("numerical_value")

let dateValue = Expression<Double?>("date_value")
let dateValue = SQLite.Expression<Double?>("date_value")

let dataValue = Expression<Data?>("data_value")
let dataValue = SQLite.Expression<Data?>("data_value")

func all(in database: Connection) throws -> [MetadataValue] {
try database.prepare(table).map(from)
Expand Down
14 changes: 7 additions & 7 deletions Sources/HealthDB/Tables/ObjectsTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ struct ObjectsTable {

let table = Table("objects")

let dataId = Expression<Int>("data_id")
let dataId = SQLite.Expression<Int>("data_id")

let uuid = Expression<Data?>("uuid")
let uuid = SQLite.Expression<Data?>("uuid")

let provenance = Expression<Int>("provenance")
let type = Expression<Int?>("type")
let creationDate = Expression<Double?>("creation_date")
let provenance = SQLite.Expression<Int>("provenance")

let type = SQLite.Expression<Int?>("type")

let creationDate = SQLite.Expression<Double?>("creation_date")

func object(for dataId: Int, in database: Connection) throws -> (uuid: UUID, provenance: Int, type: Int, creationDate: Date)? {
try database.pluck(table.filter(self.dataId == dataId)).map { row in
Expand Down
Loading

0 comments on commit b02391d

Please sign in to comment.