diff --git a/Sources/HealthDB/Model/Workouts/HKWorkoutActivity+Comparable.swift b/Sources/HealthDB/Model/Workouts/HKWorkoutActivity+Comparable.swift index 7b3fb26..65f92f4 100644 --- a/Sources/HealthDB/Model/Workouts/HKWorkoutActivity+Comparable.swift +++ b/Sources/HealthDB/Model/Workouts/HKWorkoutActivity+Comparable.swift @@ -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 diff --git a/Sources/HealthDB/Support/HKBiologicalSex+Description.swift b/Sources/HealthDB/Support/HKBiologicalSex+Description.swift index 83d8e65..fff5ff2 100644 --- a/Sources/HealthDB/Support/HKBiologicalSex+Description.swift +++ b/Sources/HealthDB/Support/HKBiologicalSex+Description.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKBiologicalSex: CustomStringConvertible { +extension HKBiologicalSex: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/HealthDB/Support/HKBloodType+Description.swift b/Sources/HealthDB/Support/HKBloodType+Description.swift index 952dc84..a87b884 100644 --- a/Sources/HealthDB/Support/HKBloodType+Description.swift +++ b/Sources/HealthDB/Support/HKBloodType+Description.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKBloodType: CustomStringConvertible { +extension HKBloodType: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/HealthDB/Support/HKFitzpatrickSkinType+Description.swift b/Sources/HealthDB/Support/HKFitzpatrickSkinType+Description.swift index 8cf3a9d..47a4202 100644 --- a/Sources/HealthDB/Support/HKFitzpatrickSkinType+Description.swift +++ b/Sources/HealthDB/Support/HKFitzpatrickSkinType+Description.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKFitzpatrickSkinType: CustomStringConvertible { +extension HKFitzpatrickSkinType: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/HealthDB/Support/HKWorkoutActivityType+Extensions.swift b/Sources/HealthDB/Support/HKWorkoutActivityType+Extensions.swift index 37d5e62..7e5aaf9 100644 --- a/Sources/HealthDB/Support/HKWorkoutActivityType+Extensions.swift +++ b/Sources/HealthDB/Support/HKWorkoutActivityType+Extensions.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKWorkoutActivityType: CustomStringConvertible { +extension HKWorkoutActivityType: @retroactive CustomStringConvertible { public var description: String { switch self { @@ -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 diff --git a/Sources/HealthDB/Support/HKWorkoutEventType+Extensions.swift b/Sources/HealthDB/Support/HKWorkoutEventType+Extensions.swift index 0e50084..d0526e9 100644 --- a/Sources/HealthDB/Support/HKWorkoutEventType+Extensions.swift +++ b/Sources/HealthDB/Support/HKWorkoutEventType+Extensions.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKWorkoutEventType: CustomStringConvertible { +extension HKWorkoutEventType: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/HealthDB/Support/HKWorkoutSessionLocationType+Extensions.swift b/Sources/HealthDB/Support/HKWorkoutSessionLocationType+Extensions.swift index 29db586..36f404c 100644 --- a/Sources/HealthDB/Support/HKWorkoutSessionLocationType+Extensions.swift +++ b/Sources/HealthDB/Support/HKWorkoutSessionLocationType+Extensions.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKWorkoutSessionLocationType: CustomStringConvertible { +extension HKWorkoutSessionLocationType: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/HealthDB/Support/HKWorkoutSwimmingLocationType+Extensions.swift b/Sources/HealthDB/Support/HKWorkoutSwimmingLocationType+Extensions.swift index 319de46..6130cf0 100644 --- a/Sources/HealthDB/Support/HKWorkoutSwimmingLocationType+Extensions.swift +++ b/Sources/HealthDB/Support/HKWorkoutSwimmingLocationType+Extensions.swift @@ -1,7 +1,7 @@ import Foundation import HealthKit -extension HKWorkoutSwimmingLocationType: CustomStringConvertible { +extension HKWorkoutSwimmingLocationType: @retroactive CustomStringConvertible { public var description: String { switch self { diff --git a/Sources/HealthDB/Tables/AssociationsTable.swift b/Sources/HealthDB/Tables/AssociationsTable.swift index a23fae5..7dcc1b9 100644 --- a/Sources/HealthDB/Tables/AssociationsTable.swift +++ b/Sources/HealthDB/Tables/AssociationsTable.swift @@ -1,17 +1,16 @@ -import Foundation import SQLite struct AssociationsTable { let table = Table("associations") - let parentId = Expression("parent_id") + let parentId = SQLite.Expression("parent_id") - let childId = Expression("child_id") + let childId = SQLite.Expression("child_id") - let syncProvenance = Expression("sync_provenance") + let syncProvenance = SQLite.Expression("sync_provenance") - let syncIdentity = Expression("sync_identity") + let syncIdentity = SQLite.Expression("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))") diff --git a/Sources/HealthDB/Tables/BinarySamplesTable.swift b/Sources/HealthDB/Tables/BinarySamplesTable.swift index cc96613..b3b1852 100644 --- a/Sources/HealthDB/Tables/BinarySamplesTable.swift +++ b/Sources/HealthDB/Tables/BinarySamplesTable.swift @@ -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("data_id") + let dataId = SQLite.Expression("data_id") - let payload = Expression("payload") + let payload = SQLite.Expression("payload") func payload(for dataId: Int, in database: Connection) throws -> Data? { try database.pluck(table.filter(self.dataId == dataId)).map { $0[payload] } diff --git a/Sources/HealthDB/Tables/CategorySamplesTable.swift b/Sources/HealthDB/Tables/CategorySamplesTable.swift index d7c8e5d..04fb761 100644 --- a/Sources/HealthDB/Tables/CategorySamplesTable.swift +++ b/Sources/HealthDB/Tables/CategorySamplesTable.swift @@ -1,4 +1,3 @@ -import Foundation import SQLite struct CategorySamplesTable { @@ -9,9 +8,9 @@ struct CategorySamplesTable { try database.execute("CREATE TABLE category_samples (data_id INTEGER PRIMARY KEY, value INTEGER)") } - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") - let value = Expression("value") + let value = SQLite.Expression("value") func value(for dataId: Int, in database: Connection) throws -> Int? { try database.pluck(table.filter(self.dataId == dataId)).map { $0[value] } diff --git a/Sources/HealthDB/Tables/DataProvenancesTable.swift b/Sources/HealthDB/Tables/DataProvenancesTable.swift index aff9dc1..5d534fc 100644 --- a/Sources/HealthDB/Tables/DataProvenancesTable.swift +++ b/Sources/HealthDB/Tables/DataProvenancesTable.swift @@ -1,4 +1,3 @@ -import Foundation import SQLite import HealthKit @@ -10,39 +9,39 @@ struct DataProvenancesTable { let table = Table("data_provenances") - let rowId = Expression("ROWID") + let rowId = SQLite.Expression("ROWID") - let syncProvenance = Expression("sync_provenance") + let syncProvenance = SQLite.Expression("sync_provenance") /// Device that created the data (e.g. Watch) - let originProductType = Expression("origin_product_type") + let originProductType = SQLite.Expression("origin_product_type") - let originBuild = Expression("origin_build") + let originBuild = SQLite.Expression("origin_build") /// Device saving the data (e.g. iPhone) - let localProductType = Expression("local_product_type") + let localProductType = SQLite.Expression("local_product_type") - let localBuild = Expression("local_build") + let localBuild = SQLite.Expression("local_build") - let sourceId = Expression("source_id") + let sourceId = SQLite.Expression("source_id") - let deviceId = Expression("device_id") + let deviceId = SQLite.Expression("device_id") - let contributorId = Expression("contributor_id") + let contributorId = SQLite.Expression("contributor_id") - let sourceVersion = Expression("source_version") + let sourceVersion = SQLite.Expression("source_version") - let tzName = Expression("tz_name") + let tzName = SQLite.Expression("tz_name") - let originMajorVersion = Expression("origin_major_version") + let originMajorVersion = SQLite.Expression("origin_major_version") - let originMinorVersion = Expression("origin_minor_version") + let originMinorVersion = SQLite.Expression("origin_minor_version") - let originPatchVersion = Expression("origin_patch_version") + let originPatchVersion = SQLite.Expression("origin_patch_version") - let syncIdentity = Expression("sync_identity") + let syncIdentity = SQLite.Expression("sync_identity") - let derivedFlags = Expression("derived_flags") + let derivedFlags = SQLite.Expression("derived_flags") func device(for rowId: Int, in database: Connection) throws -> HKDevice? { try database.pluck(table.filter(self.rowId == rowId)).map { row in diff --git a/Sources/HealthDB/Tables/DataSeriesTable.swift b/Sources/HealthDB/Tables/DataSeriesTable.swift index 906e3a7..48138d3 100644 --- a/Sources/HealthDB/Tables/DataSeriesTable.swift +++ b/Sources/HealthDB/Tables/DataSeriesTable.swift @@ -1,4 +1,3 @@ -import Foundation import SQLite struct DataSeriesTable { @@ -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("data_id") + let dataId = SQLite.Expression("data_id") - let frozen = Expression("frozen") + let frozen = SQLite.Expression("frozen") - let count = Expression("count") + let count = SQLite.Expression("count") - let insertionEra = Expression("insertion_era") + let insertionEra = SQLite.Expression("insertion_era") - let hfdKey = Expression("hfd_key") + let hfdKey = SQLite.Expression("hfd_key") - let seriesLocation = Expression("series_location") + let seriesLocation = SQLite.Expression("series_location") } diff --git a/Sources/HealthDB/Tables/ECGSamplesTable.swift b/Sources/HealthDB/Tables/ECGSamplesTable.swift index 12a05d8..aedab6b 100644 --- a/Sources/HealthDB/Tables/ECGSamplesTable.swift +++ b/Sources/HealthDB/Tables/ECGSamplesTable.swift @@ -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("data_id") + let dataId = SQLite.Expression("data_id") - let privateClassification = Expression("private_classification") + let privateClassification = SQLite.Expression("private_classification") - let averageHeartRate = Expression("average_heart_rate") + let averageHeartRate = SQLite.Expression("average_heart_rate") - let voltagePayload = Expression("voltage_payload") + let voltagePayload = SQLite.Expression("voltage_payload") - let symptomsStatus = Expression("symptoms_status") + let symptomsStatus = SQLite.Expression("symptoms_status") func payload(for dataId: Int, in database: Connection) throws -> ECGVoltageData? { try database.pluck(table.filter(self.dataId == dataId)) diff --git a/Sources/HealthDB/Tables/KeyValueSecureTable.swift b/Sources/HealthDB/Tables/KeyValueSecureTable.swift index c7049c3..ff58bb9 100644 --- a/Sources/HealthDB/Tables/KeyValueSecureTable.swift +++ b/Sources/HealthDB/Tables/KeyValueSecureTable.swift @@ -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("category") + let category = SQLite.Expression("category") - let domain = Expression("domain") + let domain = SQLite.Expression("domain") - let key = Expression("key") + let key = SQLite.Expression("key") - let dataValue = Expression("value") - let intValue = Expression("value") + let dataValue = SQLite.Expression("value") + let intValue = SQLite.Expression("value") - let provenance = Expression("provenance") + let provenance = SQLite.Expression("provenance") - let modificationDate = Expression("mod_date") + let modificationDate = SQLite.Expression("mod_date") - let syncIdentity = Expression("sync_identity") + let syncIdentity = SQLite.Expression("sync_identity") func value(for key: String, in database: Connection) throws -> T? where T: Value { try database.pluck(table.filter(self.key == key)).map { diff --git a/Sources/HealthDB/Tables/LocationSeriesDataTable.swift b/Sources/HealthDB/Tables/LocationSeriesDataTable.swift index 40be3fe..05ed4d6 100644 --- a/Sources/HealthDB/Tables/LocationSeriesDataTable.swift +++ b/Sources/HealthDB/Tables/LocationSeriesDataTable.swift @@ -7,29 +7,29 @@ struct LocationSeriesDataTable { let table = Table("location_series_data") /// `location_series_data[series_identifier]` <-> `workout_activities[ROW_ID]` - let seriesIdentifier = Expression("series_identifier") + let seriesIdentifier = SQLite.Expression("series_identifier") - let timestamp = Expression("timestamp") + let timestamp = SQLite.Expression("timestamp") - let longitude = Expression("longitude") + let longitude = SQLite.Expression("longitude") - let latitude = Expression("latitude") + let latitude = SQLite.Expression("latitude") - let altitude = Expression("altitude") + let altitude = SQLite.Expression("altitude") - let speed = Expression("speed") + let speed = SQLite.Expression("speed") - let course = Expression("course") + let course = SQLite.Expression("course") - let horizontalAccuracy = Expression("horizontal_accuracy") + let horizontalAccuracy = SQLite.Expression("horizontal_accuracy") - let verticalAccuracy = Expression("vertical_accuracy") + let verticalAccuracy = SQLite.Expression("vertical_accuracy") - let speedAccuracy = Expression("speed_accuracy") + let speedAccuracy = SQLite.Expression("speed_accuracy") - let courseAccuracy = Expression("course_accuracy") + let courseAccuracy = SQLite.Expression("course_accuracy") - let signalEnvironment = Expression("signal_environment") + let signalEnvironment = SQLite.Expression("signal_environment") func locations(for seriesId: Int, in database: Connection) throws -> [CLLocation] { let query = table.filter(seriesIdentifier == seriesId) diff --git a/Sources/HealthDB/Tables/MetadataKeysTable.swift b/Sources/HealthDB/Tables/MetadataKeysTable.swift index 0032b7b..79902aa 100644 --- a/Sources/HealthDB/Tables/MetadataKeysTable.swift +++ b/Sources/HealthDB/Tables/MetadataKeysTable.swift @@ -1,13 +1,12 @@ -import Foundation import SQLite struct MetadataKeysTable { let table = Table("metadata_keys") - let rowId = Expression("ROWID") + let rowId = SQLite.Expression("ROWID") - let key = Expression("key") + let key = SQLite.Expression("key") func create(in database: Connection) throws { //try database.execute("CREATE TABLE metadata_keys (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT UNIQUE)") diff --git a/Sources/HealthDB/Tables/MetadataValuesTable.swift b/Sources/HealthDB/Tables/MetadataValuesTable.swift index 09e18ae..e647880 100644 --- a/Sources/HealthDB/Tables/MetadataValuesTable.swift +++ b/Sources/HealthDB/Tables/MetadataValuesTable.swift @@ -1,4 +1,3 @@ -import Foundation import SQLite import HealthKit @@ -6,21 +5,21 @@ struct MetadataValuesTable { let table = Table("metadata_values") - let rowId = Expression("ROW_ID") + let rowId = SQLite.Expression("ROW_ID") - let keyId = Expression("key_id") + let keyId = SQLite.Expression("key_id") - let objectId = Expression("object_id") + let objectId = SQLite.Expression("object_id") - let valueType = Expression("value_type") + let valueType = SQLite.Expression("value_type") - let stringValue = Expression("string_value") + let stringValue = SQLite.Expression("string_value") - let numericalValue = Expression("numerical_value") + let numericalValue = SQLite.Expression("numerical_value") - let dateValue = Expression("date_value") + let dateValue = SQLite.Expression("date_value") - let dataValue = Expression("data_value") + let dataValue = SQLite.Expression("data_value") func all(in database: Connection) throws -> [MetadataValue] { try database.prepare(table).map(from) diff --git a/Sources/HealthDB/Tables/ObjectsTable.swift b/Sources/HealthDB/Tables/ObjectsTable.swift index 0f67af3..26dff34 100644 --- a/Sources/HealthDB/Tables/ObjectsTable.swift +++ b/Sources/HealthDB/Tables/ObjectsTable.swift @@ -9,15 +9,15 @@ struct ObjectsTable { let table = Table("objects") - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") - let uuid = Expression("uuid") + let uuid = SQLite.Expression("uuid") - let provenance = Expression("provenance") - - let type = Expression("type") - - let creationDate = Expression("creation_date") + let provenance = SQLite.Expression("provenance") + + let type = SQLite.Expression("type") + + let creationDate = SQLite.Expression("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 diff --git a/Sources/HealthDB/Tables/QuantitySampleSeriesTable.swift b/Sources/HealthDB/Tables/QuantitySampleSeriesTable.swift index 6e43668..169803e 100644 --- a/Sources/HealthDB/Tables/QuantitySampleSeriesTable.swift +++ b/Sources/HealthDB/Tables/QuantitySampleSeriesTable.swift @@ -10,15 +10,15 @@ struct QuantitySampleSeriesTable { try database.execute("CREATE TABLE quantity_sample_series (data_id INTEGER PRIMARY KEY REFERENCES samples (data_id) ON DELETE CASCADE, count INTEGER NOT NULL DEFAULT 0, insertion_era INTEGER, hfd_key INTEGER UNIQUE NOT NULL, series_location INTEGER NOT NULL)") } - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") - let count = Expression("count") + let count = SQLite.Expression("count") - let insertionEra = Expression("insertion_era") + let insertionEra = SQLite.Expression("insertion_era") - let hfdKey = Expression("hfd_key") + let hfdKey = SQLite.Expression("hfd_key") - let seriesLocation = Expression("series_location") + let seriesLocation = SQLite.Expression("series_location") func select(dataId id: Int, in database: Connection, sample: HKQuantitySample, identifier: HKQuantityTypeIdentifier, unit: HKUnit) throws -> HKQuantitySeries? { let query = table.filter(dataId == id) diff --git a/Sources/HealthDB/Tables/QuantitySamplesTable.swift b/Sources/HealthDB/Tables/QuantitySamplesTable.swift index bde166d..dd19dd6 100644 --- a/Sources/HealthDB/Tables/QuantitySamplesTable.swift +++ b/Sources/HealthDB/Tables/QuantitySamplesTable.swift @@ -9,14 +9,14 @@ struct QuantitySamplesTable { let table = Table("quantity_samples") - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") - let quantity = Expression("quantity") + let quantity = SQLite.Expression("quantity") - let originalQuantity = Expression("original_quantity") + let originalQuantity = SQLite.Expression("original_quantity") /// References `ROWID` on table `unit_strings` - let originalUnit = Expression("original_unit") + let originalUnit = SQLite.Expression("original_unit") func quantity(for id: Int, in database: Connection) throws -> (quantity: Double?, original: Double?, unit: Int?) { try database.prepare(table.filter(dataId == id).limit(1)).map { diff --git a/Sources/HealthDB/Tables/QuantitySeriesDataTable.swift b/Sources/HealthDB/Tables/QuantitySeriesDataTable.swift index f1ce98f..cf835be 100644 --- a/Sources/HealthDB/Tables/QuantitySeriesDataTable.swift +++ b/Sources/HealthDB/Tables/QuantitySeriesDataTable.swift @@ -10,13 +10,13 @@ struct QuantitySeriesDataTable { try database.execute("CREATE TABLE quantity_series_data (series_identifier INTEGER NOT NULL REFERENCES quantity_sample_series(hfd_key) DEFERRABLE INITIALLY DEFERRED, timestamp REAL NOT NULL, value REAL NOT NULL, duration REAL NOT NULL, PRIMARY KEY (series_identifier, timestamp)) WITHOUT ROWID") } - let seriesIdentifier = Expression("series_identifier") + let seriesIdentifier = SQLite.Expression("series_identifier") - let timestamp = Expression("timestamp") + let timestamp = SQLite.Expression("timestamp") - let value = Expression("value") + let value = SQLite.Expression("value") - let duration = Expression("duration") + let duration = SQLite.Expression("duration") func quantities(for dataId: Int, in database: Connection, identifier: HKQuantityTypeIdentifier, unit: HKUnit) throws -> [HKQuantitySample] { let query = table.filter(seriesIdentifier == dataId) diff --git a/Sources/HealthDB/Tables/SamplesTable.swift b/Sources/HealthDB/Tables/SamplesTable.swift index a171f29..637fd39 100644 --- a/Sources/HealthDB/Tables/SamplesTable.swift +++ b/Sources/HealthDB/Tables/SamplesTable.swift @@ -9,15 +9,15 @@ struct SamplesTable { let table = Table("samples") - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") // NOTE: Technically optional - let startDate = Expression("start_date") + let startDate = SQLite.Expression("start_date") // NOTE: Technically optional - let endDate = Expression("end_date") + let endDate = SQLite.Expression("end_date") - let dataType = Expression("data_type") + let dataType = SQLite.Expression("data_type") /// Select samples of a type overlapping with the given date interval. func query(type: SampleType, from start: Date, to end: Date) -> Table { diff --git a/Sources/HealthDB/Tables/ScoredAssessmentSamples.swift b/Sources/HealthDB/Tables/ScoredAssessmentSamples.swift index 9ccdc0e..5efbff6 100644 --- a/Sources/HealthDB/Tables/ScoredAssessmentSamples.swift +++ b/Sources/HealthDB/Tables/ScoredAssessmentSamples.swift @@ -9,13 +9,13 @@ struct ScoredAssessmentSamples { let table = Table("scored_assessment_samples") - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") // NOTE: Technically optional - let score = Expression("score") + let score = SQLite.Expression("score") // NOTE: Technically optional - let answers = Expression("answers") + let answers = SQLite.Expression("answers") - let risk = Expression("risk") + let risk = SQLite.Expression("risk") } diff --git a/Sources/HealthDB/Tables/SleepScheduleSamples.swift b/Sources/HealthDB/Tables/SleepScheduleSamples.swift index b4e02c8..b4ab0fa 100644 --- a/Sources/HealthDB/Tables/SleepScheduleSamples.swift +++ b/Sources/HealthDB/Tables/SleepScheduleSamples.swift @@ -5,31 +5,31 @@ struct SleepScheduleSamples { let table = Table("sleep_schedule_samples") - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") - let monday = Expression("monday") + let monday = SQLite.Expression("monday") - let tuesday = Expression("tuesday") + let tuesday = SQLite.Expression("tuesday") - let wednesday = Expression("wednesday") + let wednesday = SQLite.Expression("wednesday") - let thursday = Expression("thursday") + let thursday = SQLite.Expression("thursday") - let friday = Expression("friday") + let friday = SQLite.Expression("friday") - let saturday = Expression("saturday") + let saturday = SQLite.Expression("saturday") - let sunday = Expression("sunday") + let sunday = SQLite.Expression("sunday") - let wakeHour = Expression("wake_hour") + let wakeHour = SQLite.Expression("wake_hour") - let wakeMinute = Expression("wake_minute") + let wakeMinute = SQLite.Expression("wake_minute") - let bedHour = Expression("bed_hour") + let bedHour = SQLite.Expression("bed_hour") - let bedMinute = Expression("bed_minute") + let bedMinute = SQLite.Expression("bed_minute") - let overrideDayIndex = Expression("override_day_index") + let overrideDayIndex = SQLite.Expression("override_day_index") func create(in database: Connection) throws { try database.execute("CREATE TABLE sleep_schedule_samples (data_id INTEGER PRIMARY KEY, monday INTEGER NOT NULL, tuesday INTEGER NOT NULL, wednesday INTEGER NOT NULL, thursday INTEGER NOT NULL, friday INTEGER NOT NULL, saturday INTEGER NOT NULL, sunday INTEGER NOT NULL, wake_hour INTEGER, wake_minute INTEGER, bed_hour INTEGER, bed_minute INTEGER, override_day_index INTEGER)") diff --git a/Sources/HealthDB/Tables/UnitStringsTable.swift b/Sources/HealthDB/Tables/UnitStringsTable.swift index 9918fdc..35cdaf6 100644 --- a/Sources/HealthDB/Tables/UnitStringsTable.swift +++ b/Sources/HealthDB/Tables/UnitStringsTable.swift @@ -9,9 +9,9 @@ struct UnitStringsTable { let table = Table("unit_strings") - let rowId = Expression("ROWID") + let rowId = SQLite.Expression("ROWID") - let unitString = Expression("unit_string") + let unitString = SQLite.Expression("unit_string") func unit(for id: Int, database: Connection) throws -> String? { guard let row = try database.pluck(table.filter(rowId == id)) else { diff --git a/Sources/HealthDB/Tables/WorkoutActivitiesTable.swift b/Sources/HealthDB/Tables/WorkoutActivitiesTable.swift index 713f972..0f2416e 100644 --- a/Sources/HealthDB/Tables/WorkoutActivitiesTable.swift +++ b/Sources/HealthDB/Tables/WorkoutActivitiesTable.swift @@ -6,29 +6,29 @@ struct WorkoutActivitiesTable { let table = Table("workout_activities") - let rowId = Expression("ROWID") + let rowId = SQLite.Expression("ROWID") - let uuid = Expression("uuid") + let uuid = SQLite.Expression("uuid") - let ownerId = Expression("owner_id") + let ownerId = SQLite.Expression("owner_id") - let isPrimaryActivity = Expression("is_primary_activity") + let isPrimaryActivity = SQLite.Expression("is_primary_activity") - let activityType = Expression("activity_type") + let activityType = SQLite.Expression("activity_type") - let locationType = Expression("location_type") + let locationType = SQLite.Expression("location_type") - let swimmingLocationType = Expression("swimming_location_type") + let swimmingLocationType = SQLite.Expression("swimming_location_type") - let lapLength = Expression("lap_length") + let lapLength = SQLite.Expression("lap_length") - let startDate = Expression("start_date") + let startDate = SQLite.Expression("start_date") - let endDate = Expression("end_date") + let endDate = SQLite.Expression("end_date") - let duration = Expression("duration") + let duration = SQLite.Expression("duration") - let metadata = Expression("metadata") + let metadata = SQLite.Expression("metadata") func activities(in database: Connection) throws -> [HKWorkoutActivity] { try database.prepare(table).map(activity) diff --git a/Sources/HealthDB/Tables/WorkoutEventsTable.swift b/Sources/HealthDB/Tables/WorkoutEventsTable.swift index 93ced06..f5660f6 100644 --- a/Sources/HealthDB/Tables/WorkoutEventsTable.swift +++ b/Sources/HealthDB/Tables/WorkoutEventsTable.swift @@ -7,28 +7,28 @@ struct WorkoutEventsTable { let table = Table("workout_events") // INTEGER PRIMARY KEY AUTOINCREMENT - let rowId = Expression("ROWID") + let rowId = SQLite.Expression("ROWID") // owner_id INTEGER NOT NULL REFERENCES workouts (data_id) ON DELETE CASCADE - let ownerId = Expression("owner_id") + let ownerId = SQLite.Expression("owner_id") // date REAL NOT NULL - let date = Expression("date") + let date = SQLite.Expression("date") // type INTEGER NOT NULL - let type = Expression("type") + let type = SQLite.Expression("type") // duration REAL NOT NULL - let duration = Expression("duration") + let duration = SQLite.Expression("duration") // metadata BLOB - let metadata = Expression("metadata") + let metadata = SQLite.Expression("metadata") // session_uuid BLOB - let sessionUUID = Expression("session_uuid") + let sessionUUID = SQLite.Expression("session_uuid") // error BLOB - let error = Expression("error") + let error = SQLite.Expression("error") func events(in database: Connection) throws -> [HKWorkoutEvent] { try database.prepare(table).map(event) diff --git a/Sources/HealthDB/Tables/WorkoutStatisticsTable.swift b/Sources/HealthDB/Tables/WorkoutStatisticsTable.swift index e5155ce..a603a55 100644 --- a/Sources/HealthDB/Tables/WorkoutStatisticsTable.swift +++ b/Sources/HealthDB/Tables/WorkoutStatisticsTable.swift @@ -10,15 +10,15 @@ struct WorkoutStatisticsTable { try database.execute("CREATE TABLE workout_statistics (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, workout_activity_id INTEGER NOT NULL REFERENCES workout_activities(ROWID) ON DELETE CASCADE, data_type INTEGER NOT NULL, quantity REAL NOT NULL, min REAL, max REAL, UNIQUE(workout_activity_id, data_type))") } - let workoutActivityId = Expression("workout_activity_id") + let workoutActivityId = SQLite.Expression("workout_activity_id") - let dataType = Expression("data_type") + let dataType = SQLite.Expression("data_type") - let quantity = Expression("quantity") + let quantity = SQLite.Expression("quantity") - let min = Expression("min") + let min = SQLite.Expression("min") - let max = Expression("max") + let max = SQLite.Expression("max") func createStatistics(from row: Row, type: HKQuantityType, unit: HKUnit) -> Statistics { .init(quantityType: type, diff --git a/Sources/HealthDB/Tables/WorkoutsTable.swift b/Sources/HealthDB/Tables/WorkoutsTable.swift index f89716d..e6a955c 100644 --- a/Sources/HealthDB/Tables/WorkoutsTable.swift +++ b/Sources/HealthDB/Tables/WorkoutsTable.swift @@ -7,22 +7,22 @@ struct WorkoutsTable { let table = Table("workouts") // INTEGER PRIMARY KEY AUTOINCREMENT - let dataId = Expression("data_id") + let dataId = SQLite.Expression("data_id") // REAL - let totalDistance = Expression("total_distance") + let totalDistance = SQLite.Expression("total_distance") // INTEGER - let goalType = Expression("goal_type") + let goalType = SQLite.Expression("goal_type") // REAL - let goal = Expression("goal") + let goal = SQLite.Expression("goal") // INTEGER - let condenserVersion = Expression("condenser_version") + let condenserVersion = SQLite.Expression("condenser_version") // REAL - let condenserDate = Expression("condenser_date") + let condenserDate = SQLite.Expression("condenser_date") func create(in database: Connection) throws { try database.run(table.create { t in