From 9c6a81437cc78f4c271c6c7490a8bd9bdbc1f752 Mon Sep 17 00:00:00 2001 From: Oleksii Zghurskyi Date: Fri, 24 Oct 2025 20:16:30 +0300 Subject: [PATCH] Update dependencies --- Package.swift | 2 +- .../DLCDecoder/Classes/KeyedContainer.swift | 2 +- .../DLCDecoder/Classes/MultiRowDecoder.swift | 2 +- .../DLCDecoder/Classes/SingleRowDecoder.swift | 2 +- .../Classes/SingleValueContainer.swift | 2 +- .../Classes/SingleValueDecoder.swift | 6 +- .../DLCDecoder/Classes/UnkeyedContainer.swift | 2 +- Sources/DLCDecoder/Protocols/RowDecoder.swift | 2 +- .../DLCDecoder/Protocols/ValueDecoder.swift | 2 +- .../DLCEncoder/Classes/KeyedContainer.swift | 2 +- .../DLCEncoder/Classes/MultiRowEncoder.swift | 2 +- .../DLCEncoder/Classes/SingleRowEncoder.swift | 8 +- .../Classes/SingleValueContainer.swift | 2 +- .../Classes/SingleValueEncoder.swift | 6 +- Sources/DLCEncoder/Protocols/RowEncoder.swift | 2 +- .../DLCEncoder/Protocols/ValueEncoder.swift | 2 +- .../DataLiteCoder/Classes/DateEncoder.swift | 2 +- .../Enums/DateDecodingStrategy.swift | 4 +- .../Enums/DateEncodingStrategy.swift | 4 +- .../DLCDecoderTests/KeyedContainerTests.swift | 8 +- .../SingleRowDecoderTests.swift | 2 +- .../SingleValueContainerTests.swift | 8 +- .../SingleValueDecoderTests.swift | 4 +- .../UnkeyedContainerTests.swift | 10 +-- .../DLCEncoderTests/KeyedContainerTests.swift | 18 ++--- .../SingleRowEncoderTests.swift | 8 +- .../SingleValueContainerTests.swift | 10 +-- .../SingleValueEncoderTests.swift | 2 +- .../UnkeyedContainerTests.swift | 10 +-- .../DataLiteCoderTests/DateDecoderTests.swift | 8 +- .../DataLiteCoderTests/DateEncoderTests.swift | 14 ++-- .../DataLiteCoderTests/RowDecoderTests.swift | 76 +++++++++---------- .../DataLiteCoderTests/RowEncoderTests.swift | 10 +-- 33 files changed, 122 insertions(+), 122 deletions(-) diff --git a/Package.swift b/Package.swift index a18fa4f..cc2a91a 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,7 @@ let package = Package( dependencies: [ .package( url: "https://github.com/angd-dev/data-lite-core.git", - revision: "b4e9755c153d3ccca575a5845fff5bbc4f93fcf5" + revision: "2b3ba846b06f865616787edfdb47f503317a0dc0" ), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0") ], diff --git a/Sources/DLCDecoder/Classes/KeyedContainer.swift b/Sources/DLCDecoder/Classes/KeyedContainer.swift index 0c55515..091c37d 100644 --- a/Sources/DLCDecoder/Classes/KeyedContainer.swift +++ b/Sources/DLCDecoder/Classes/KeyedContainer.swift @@ -34,7 +34,7 @@ final class KeyedContainer( + public func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { diff --git a/Sources/DLCDecoder/Classes/SingleRowDecoder.swift b/Sources/DLCDecoder/Classes/SingleRowDecoder.swift index 389682e..0c42603 100644 --- a/Sources/DLCDecoder/Classes/SingleRowDecoder.swift +++ b/Sources/DLCDecoder/Classes/SingleRowDecoder.swift @@ -49,7 +49,7 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { try dateDecoder.decode(from: self, for: key) } - public func decode( + public func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { diff --git a/Sources/DLCDecoder/Classes/SingleValueContainer.swift b/Sources/DLCDecoder/Classes/SingleValueContainer.swift index 2ec39c6..6e9116c 100644 --- a/Sources/DLCDecoder/Classes/SingleValueContainer.swift +++ b/Sources/DLCDecoder/Classes/SingleValueContainer.swift @@ -27,7 +27,7 @@ final class SingleValueContainer: Container, SingleValueD switch type { case is Date.Type: try decoder.decodeDate() as! T - case let type as SQLiteRawRepresentable.Type: + case let type as SQLiteRepresentable.Type: try decoder.decode(type) as! T default: try T(from: decoder) diff --git a/Sources/DLCDecoder/Classes/SingleValueDecoder.swift b/Sources/DLCDecoder/Classes/SingleValueDecoder.swift index ae84c04..b87897a 100644 --- a/Sources/DLCDecoder/Classes/SingleValueDecoder.swift +++ b/Sources/DLCDecoder/Classes/SingleValueDecoder.swift @@ -5,7 +5,7 @@ final class SingleValueDecoder: ValueDecoder { // MARK: - Properties let dateDecoder: any DateDecoder - let sqliteData: SQLiteRawValue + let sqliteData: SQLiteValue let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey: Any] @@ -13,7 +13,7 @@ final class SingleValueDecoder: ValueDecoder { init( dateDecoder: any DateDecoder, - sqliteData: SQLiteRawValue, + sqliteData: SQLiteValue, codingPath: [any CodingKey], userInfo: [CodingUserInfoKey: Any] ) { @@ -33,7 +33,7 @@ final class SingleValueDecoder: ValueDecoder { try dateDecoder.decode(from: self) } - func decode(_ type: T.Type) throws -> T { + func decode(_ type: T.Type) throws -> T { guard sqliteData != .null else { let info = "Cannot get value of type \(T.self), found null value instead." let context = DecodingError.Context( diff --git a/Sources/DLCDecoder/Classes/UnkeyedContainer.swift b/Sources/DLCDecoder/Classes/UnkeyedContainer.swift index c9bb40e..6603783 100644 --- a/Sources/DLCDecoder/Classes/UnkeyedContainer.swift +++ b/Sources/DLCDecoder/Classes/UnkeyedContainer.swift @@ -52,7 +52,7 @@ final class UnkeyedContainer: Container, UnkeyedDecodingCon switch type { case is Date.Type: return try decoder.decodeDate(for: currentKey) as! T - case let type as SQLiteRawRepresentable.Type: + case let type as SQLiteRepresentable.Type: return try decoder.decode(type, for: currentKey) as! T default: return try T(from: decoder.decoder(for: currentKey)) diff --git a/Sources/DLCDecoder/Protocols/RowDecoder.swift b/Sources/DLCDecoder/Protocols/RowDecoder.swift index f6b4c07..b0d77bf 100644 --- a/Sources/DLCDecoder/Protocols/RowDecoder.swift +++ b/Sources/DLCDecoder/Protocols/RowDecoder.swift @@ -6,6 +6,6 @@ public protocol RowDecoder: Decoder { func decodeNil(for key: CodingKey) throws -> Bool func decodeDate(for key: CodingKey) throws -> Date - func decode(_ type: T.Type, for key: CodingKey) throws -> T + func decode(_ type: T.Type, for key: CodingKey) throws -> T func decoder(for key: CodingKey) throws -> any Decoder } diff --git a/Sources/DLCDecoder/Protocols/ValueDecoder.swift b/Sources/DLCDecoder/Protocols/ValueDecoder.swift index 211d362..4591052 100644 --- a/Sources/DLCDecoder/Protocols/ValueDecoder.swift +++ b/Sources/DLCDecoder/Protocols/ValueDecoder.swift @@ -4,5 +4,5 @@ import DataLiteCore public protocol ValueDecoder: Decoder { func decodeNil() -> Bool func decodeDate() throws -> Date - func decode(_ type: T.Type) throws -> T + func decode(_ type: T.Type) throws -> T } diff --git a/Sources/DLCEncoder/Classes/KeyedContainer.swift b/Sources/DLCEncoder/Classes/KeyedContainer.swift index 5ae0f04..874f2b1 100644 --- a/Sources/DLCEncoder/Classes/KeyedContainer.swift +++ b/Sources/DLCEncoder/Classes/KeyedContainer.swift @@ -29,7 +29,7 @@ final class KeyedContainer: Container, Keye switch value { case let value as Date: try encoder.encodeDate(value, for: key) - case let value as SQLiteRawBindable: + case let value as SQLiteBindable: try encoder.encode(value, for: key) default: let valueEncoder = try encoder.encoder(for: key) diff --git a/Sources/DLCEncoder/Classes/MultiRowEncoder.swift b/Sources/DLCEncoder/Classes/MultiRowEncoder.swift index 6ec6c65..a297872 100644 --- a/Sources/DLCEncoder/Classes/MultiRowEncoder.swift +++ b/Sources/DLCEncoder/Classes/MultiRowEncoder.swift @@ -59,7 +59,7 @@ public final class MultiRowEncoder: RowEncoder { throw EncodingError.invalidValue(date, context) } - public func encode(_ value: T, for key: any CodingKey) throws { + public func encode(_ value: T, for key: any CodingKey) throws { let info = "Attempted to encode \(T.self), but it's not supported." let context = EncodingError.Context( codingPath: codingPath + [key], diff --git a/Sources/DLCEncoder/Classes/SingleRowEncoder.swift b/Sources/DLCEncoder/Classes/SingleRowEncoder.swift index 5efe985..aed6573 100644 --- a/Sources/DLCEncoder/Classes/SingleRowEncoder.swift +++ b/Sources/DLCEncoder/Classes/SingleRowEncoder.swift @@ -29,8 +29,8 @@ public final class SingleRowEncoder: RowEncoder { // MARK: - Methods public func set(_ value: Any, for key: any CodingKey) throws { - guard let value = value as? SQLiteRawValue else { - let info = "The value does not match \(SQLiteRawValue.self)" + guard let value = value as? SQLiteValue else { + let info = "The value does not match \(SQLiteValue.self)" let context = EncodingError.Context( codingPath: codingPath + [key], debugDescription: info @@ -48,8 +48,8 @@ public final class SingleRowEncoder: RowEncoder { try dateEncoder.encode(date, for: key, to: self) } - public func encode(_ value: T, for key: any CodingKey) throws { - sqliteData[key] = value.sqliteRawValue + public func encode(_ value: T, for key: any CodingKey) throws { + sqliteData[key] = value.sqliteValue } public func encoder(for key: any CodingKey) throws -> any Encoder { diff --git a/Sources/DLCEncoder/Classes/SingleValueContainer.swift b/Sources/DLCEncoder/Classes/SingleValueContainer.swift index 3ea44d8..a5a3faf 100644 --- a/Sources/DLCEncoder/Classes/SingleValueContainer.swift +++ b/Sources/DLCEncoder/Classes/SingleValueContainer.swift @@ -27,7 +27,7 @@ final class SingleValueContainer: Container, SingleValueE switch value { case let value as Date: try encoder.encodeDate(value) - case let value as SQLiteRawBindable: + case let value as SQLiteBindable: try encoder.encode(value) default: try value.encode(to: encoder) diff --git a/Sources/DLCEncoder/Classes/SingleValueEncoder.swift b/Sources/DLCEncoder/Classes/SingleValueEncoder.swift index eb56373..f0dae31 100644 --- a/Sources/DLCEncoder/Classes/SingleValueEncoder.swift +++ b/Sources/DLCEncoder/Classes/SingleValueEncoder.swift @@ -10,7 +10,7 @@ final class SingleValueEncoder: ValueEncoder { let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey: Any] - private(set) var sqliteData: SQLiteRawValue? + private(set) var sqliteData: SQLiteValue? // MARK: - Inits @@ -34,8 +34,8 @@ final class SingleValueEncoder: ValueEncoder { try dateEncoder.encode(date, to: self) } - func encode(_ value: T) throws { - sqliteData = value.sqliteRawValue + func encode(_ value: T) throws { + sqliteData = value.sqliteValue } func container( diff --git a/Sources/DLCEncoder/Protocols/RowEncoder.swift b/Sources/DLCEncoder/Protocols/RowEncoder.swift index f1eb550..16bff49 100644 --- a/Sources/DLCEncoder/Protocols/RowEncoder.swift +++ b/Sources/DLCEncoder/Protocols/RowEncoder.swift @@ -7,6 +7,6 @@ public protocol RowEncoder: Encoder { func set(_ value: Any, for key: CodingKey) throws func encodeNil(for key: CodingKey) throws func encodeDate(_ date: Date, for key: CodingKey) throws - func encode(_ value: T, for key: CodingKey) throws + func encode(_ value: T, for key: CodingKey) throws func encoder(for key: CodingKey) throws -> any Encoder } diff --git a/Sources/DLCEncoder/Protocols/ValueEncoder.swift b/Sources/DLCEncoder/Protocols/ValueEncoder.swift index d09fdbc..73d8924 100644 --- a/Sources/DLCEncoder/Protocols/ValueEncoder.swift +++ b/Sources/DLCEncoder/Protocols/ValueEncoder.swift @@ -4,5 +4,5 @@ import DataLiteCore public protocol ValueEncoder: Encoder { func encodeNil() throws func encodeDate(_ date: Date) throws - func encode(_ value: T) throws + func encode(_ value: T) throws } diff --git a/Sources/DataLiteCoder/Classes/DateEncoder.swift b/Sources/DataLiteCoder/Classes/DateEncoder.swift index 0f99b5d..20a3188 100644 --- a/Sources/DataLiteCoder/Classes/DateEncoder.swift +++ b/Sources/DataLiteCoder/Classes/DateEncoder.swift @@ -31,7 +31,7 @@ extension RowEncoder { try encoder.encode(value, for: key) } - private func encodeValue(from date: Date) -> SQLiteRawBindable { + private func encodeValue(from date: Date) -> SQLiteBindable { switch strategy { case .deferredToDate: date diff --git a/Sources/DataLiteCoder/Enums/DateDecodingStrategy.swift b/Sources/DataLiteCoder/Enums/DateDecodingStrategy.swift index 420f1b2..93c50b5 100644 --- a/Sources/DataLiteCoder/Enums/DateDecodingStrategy.swift +++ b/Sources/DataLiteCoder/Enums/DateDecodingStrategy.swift @@ -28,9 +28,9 @@ extension RowDecoder { /// - ``secondsSince1970Int`` /// - ``secondsSince1970Double`` public enum DateDecodingStrategy { - /// Decode dates by using the implementation of the `SQLiteRawRepresentable` protocol. + /// Decode dates by using the implementation of the `SQLiteRepresentable` protocol. /// - /// This strategy relies on the type’s conformance to `SQLiteRawRepresentable` + /// This strategy relies on the type’s conformance to `SQLiteRepresentable` /// to decode the date value from SQLite data. case deferredToDate diff --git a/Sources/DataLiteCoder/Enums/DateEncodingStrategy.swift b/Sources/DataLiteCoder/Enums/DateEncodingStrategy.swift index ff55d01..bac3171 100644 --- a/Sources/DataLiteCoder/Enums/DateEncodingStrategy.swift +++ b/Sources/DataLiteCoder/Enums/DateEncodingStrategy.swift @@ -28,9 +28,9 @@ extension RowEncoder { /// - ``secondsSince1970Int`` /// - ``secondsSince1970Double`` public enum DateEncodingStrategy { - /// Encode dates by using the implementation of the `SQLiteRawRepresentable` protocol. + /// Encode dates by using the implementation of the `SQLiteRepresentable` protocol. /// - /// This strategy relies on the type’s conformance to `SQLiteRawRepresentable` + /// This strategy relies on the type’s conformance to `SQLiteRepresentable` /// to encode the date value into a SQLite-compatible representation. case deferredToDate diff --git a/Tests/DLCDecoderTests/KeyedContainerTests.swift b/Tests/DLCDecoderTests/KeyedContainerTests.swift index d6cbfb6..135941e 100644 --- a/Tests/DLCDecoderTests/KeyedContainerTests.swift +++ b/Tests/DLCDecoderTests/KeyedContainerTests.swift @@ -292,7 +292,7 @@ private extension KeyedContainerTests { case key3 } - enum RawRepresentableEnum: String, Decodable, SQLiteRawRepresentable { + enum RawRepresentableEnum: String, Decodable, SQLiteRepresentable { case test } @@ -351,7 +351,7 @@ private extension KeyedContainerTests { try dateDecoder.decode(from: self, for: key) } - func decode( + func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { @@ -378,7 +378,7 @@ private extension KeyedContainerTests { } final class MockValueDecoder: ValueDecoder, SingleValueDecodingContainer { - typealias SQLiteData = SQLiteRawValue + typealias SQLiteData = SQLiteValue let sqliteData: SQLiteData var dateDecoder: DateDecoder @@ -405,7 +405,7 @@ private extension KeyedContainerTests { fatalError() } - func decode( + func decode( _ type: T.Type ) throws -> T { fatalError() diff --git a/Tests/DLCDecoderTests/SingleRowDecoderTests.swift b/Tests/DLCDecoderTests/SingleRowDecoderTests.swift index 812a690..98cd912 100644 --- a/Tests/DLCDecoderTests/SingleRowDecoderTests.swift +++ b/Tests/DLCDecoderTests/SingleRowDecoderTests.swift @@ -102,7 +102,7 @@ final class SingleRowDecoderTests: XCTestCase { } XCTAssertTrue(type == Data.self) XCTAssertEqual(context.codingPath as? [DummyKey], path + [testKey]) - XCTAssertEqual(context.debugDescription, "Expected to decode Data but found an \(SQLiteRawValue.int(0)) instead.") + XCTAssertEqual(context.debugDescription, "Expected to decode Data but found an \(SQLiteValue.int(0)) instead.") } } diff --git a/Tests/DLCDecoderTests/SingleValueContainerTests.swift b/Tests/DLCDecoderTests/SingleValueContainerTests.swift index 11f7185..73d4505 100644 --- a/Tests/DLCDecoderTests/SingleValueContainerTests.swift +++ b/Tests/DLCDecoderTests/SingleValueContainerTests.swift @@ -153,7 +153,7 @@ final class SingleValueContainerTests: XCTestCase { } private extension SingleValueContainerTests { - enum RawRepresentableEnum: String, Decodable, SQLiteRawRepresentable { + enum RawRepresentableEnum: String, Decodable, SQLiteRepresentable { case test } @@ -177,13 +177,13 @@ private extension SingleValueContainerTests { } final class MockSingleValueDecoder: ValueDecoder, SingleValueDecodingContainer { - let sqliteData: SQLiteRawValue + let sqliteData: SQLiteValue let dateDecoder: DateDecoder let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey: Any] init( - sqliteData: SQLiteRawValue, + sqliteData: SQLiteValue, dateDecoder: DateDecoder = MockDateDecoder(), codingPath: [any CodingKey] = [], userInfo: [CodingUserInfoKey: Any] = [:] @@ -202,7 +202,7 @@ private extension SingleValueContainerTests { try dateDecoder.decode(from: self) } - func decode( + func decode( _ type: T.Type ) throws -> T { type.init(sqliteData)! diff --git a/Tests/DLCDecoderTests/SingleValueDecoderTests.swift b/Tests/DLCDecoderTests/SingleValueDecoderTests.swift index 0932520..9138789 100644 --- a/Tests/DLCDecoderTests/SingleValueDecoderTests.swift +++ b/Tests/DLCDecoderTests/SingleValueDecoderTests.swift @@ -42,7 +42,7 @@ final class SingleValueDecoderTests: XCTestCase { } XCTAssertTrue(type == Data.self) XCTAssertEqual(context.codingPath as? [DummyKey], decoder.codingPath as? [DummyKey]) - XCTAssertEqual(context.debugDescription, "Expected to decode Data but found an \(SQLiteRawValue.int(0)) instead.") + XCTAssertEqual(context.debugDescription, "Expected to decode Data but found an \(SQLiteValue.int(0)) instead.") } } @@ -99,7 +99,7 @@ final class SingleValueDecoderTests: XCTestCase { private extension SingleValueDecoderTests { func decoder( dateDecoder: DateDecoder = MockDateDecoder(), - sqliteData: SQLiteRawValue, + sqliteData: SQLiteValue, codingPath: [any CodingKey] = [] ) -> SingleValueDecoder { SingleValueDecoder( diff --git a/Tests/DLCDecoderTests/UnkeyedContainerTests.swift b/Tests/DLCDecoderTests/UnkeyedContainerTests.swift index 188f06f..8ef9178 100644 --- a/Tests/DLCDecoderTests/UnkeyedContainerTests.swift +++ b/Tests/DLCDecoderTests/UnkeyedContainerTests.swift @@ -488,7 +488,7 @@ final class UnkeyedContainerTests: XCTestCase { private extension UnkeyedContainerTests { func container( - withData data: SQLiteRawValue, + withData data: SQLiteValue, codingPath: [any CodingKey] = [] ) -> UnkeyedContainer { var row = SQLiteRow() @@ -535,7 +535,7 @@ private extension UnkeyedContainerTests { } private extension UnkeyedContainerTests { - enum RawRepresentableEnum: String, Decodable, SQLiteRawRepresentable { + enum RawRepresentableEnum: String, Decodable, SQLiteRepresentable { case test } @@ -596,7 +596,7 @@ private extension UnkeyedContainerTests { try dateDecoder.decode(from: self, for: key) } - func decode( + func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { @@ -623,7 +623,7 @@ private extension UnkeyedContainerTests { } final class MockValueDecoder: ValueDecoder, SingleValueDecodingContainer { - typealias SQLiteData = SQLiteRawValue + typealias SQLiteData = SQLiteValue let sqliteData: SQLiteData var dateDecoder: DateDecoder @@ -650,7 +650,7 @@ private extension UnkeyedContainerTests { fatalError() } - func decode( + func decode( _ type: T.Type ) throws -> T { fatalError() diff --git a/Tests/DLCEncoderTests/KeyedContainerTests.swift b/Tests/DLCEncoderTests/KeyedContainerTests.swift index f41ee75..cf628b4 100644 --- a/Tests/DLCEncoderTests/KeyedContainerTests.swift +++ b/Tests/DLCEncoderTests/KeyedContainerTests.swift @@ -353,7 +353,7 @@ private extension KeyedContainerTests { case key3 } - enum RawRepresentableModel: String, Encodable, SQLiteRawRepresentable { + enum RawRepresentableModel: String, Encodable, SQLiteRepresentable { case test } @@ -393,7 +393,7 @@ private extension KeyedContainerTests { } func set(_ value: Any, for key: any CodingKey) throws { - guard let value = value as? SQLiteRawValue else { + guard let value = value as? SQLiteValue else { fatalError() } sqliteData[key.stringValue] = value @@ -407,8 +407,8 @@ private extension KeyedContainerTests { try dateEncoder.encode(date, for: key, to: self) } - func encode(_ value: T, for key: any CodingKey) throws { - sqliteData[key.stringValue] = value.sqliteRawValue + func encode(_ value: T, for key: any CodingKey) throws { + sqliteData[key.stringValue] = value.sqliteValue } func encoder(for key: any CodingKey) throws -> any Encoder { @@ -431,13 +431,13 @@ private extension KeyedContainerTests { } final class MockSingleValueEncoder: ValueEncoder { - private(set) var sqliteData: SQLiteRawValue? + private(set) var sqliteData: SQLiteValue? let dateEncoder: any DateEncoder let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey: Any] init( - sqliteData: SQLiteRawValue? = nil, + sqliteData: SQLiteValue? = nil, dateEncoder: any DateEncoder = MockDateEncoder(), codingPath: [any CodingKey] = [], userInfo: [CodingUserInfoKey: Any] = [:] @@ -456,8 +456,8 @@ private extension KeyedContainerTests { try dateEncoder.encode(date, to: self) } - func encode(_ value: T) throws { - sqliteData = value.sqliteRawValue + func encode(_ value: T) throws { + sqliteData = value.sqliteValue } func container( @@ -495,7 +495,7 @@ private extension KeyedContainerTests { switch value { case let value as Date: try encoder.encodeDate(value) - case let value as SQLiteRawRepresentable: + case let value as SQLiteRepresentable: try encoder.encode(value) default: try value.encode(to: encoder) diff --git a/Tests/DLCEncoderTests/SingleRowEncoderTests.swift b/Tests/DLCEncoderTests/SingleRowEncoderTests.swift index fc88cd6..bbbb7dc 100644 --- a/Tests/DLCEncoderTests/SingleRowEncoderTests.swift +++ b/Tests/DLCEncoderTests/SingleRowEncoderTests.swift @@ -11,8 +11,8 @@ final class SingleRowEncoderTests: XCTestCase { codingPath: [], userInfo: [:] ) - try encoder.set(SQLiteRawValue.int(42), for: CodingKeys.key1) - try encoder.set(SQLiteRawValue.real(3.14), for: CodingKeys.key2) + try encoder.set(SQLiteValue.int(42), for: CodingKeys.key1) + try encoder.set(SQLiteValue.real(3.14), for: CodingKeys.key2) XCTAssertEqual(encoder.sqliteData[CodingKeys.key1], .int(42)) XCTAssertEqual(encoder.sqliteData[CodingKeys.key2], .real(3.14)) XCTAssertEqual(encoder.count, encoder.sqliteData.count) @@ -34,7 +34,7 @@ final class SingleRowEncoderTests: XCTestCase { } XCTAssertEqual(thrownValue as? String, value) XCTAssertEqual(context.codingPath as? [CodingKeys], path + [.key2]) - XCTAssertEqual(context.debugDescription, "The value does not match SQLiteRawValue") + XCTAssertEqual(context.debugDescription, "The value does not match SQLiteValue") } } @@ -61,7 +61,7 @@ final class SingleRowEncoderTests: XCTestCase { try encoder.encodeDate(date, for: CodingKeys.key1) XCTAssertTrue(mockDateEncoder.didCallEncode) - XCTAssertEqual(encoder.sqliteData[CodingKeys.key1], date.sqliteRawValue) + XCTAssertEqual(encoder.sqliteData[CodingKeys.key1], date.sqliteValue) XCTAssertEqual(encoder.count, encoder.sqliteData.count) } diff --git a/Tests/DLCEncoderTests/SingleValueContainerTests.swift b/Tests/DLCEncoderTests/SingleValueContainerTests.swift index 5a6f8c0..bf323c1 100644 --- a/Tests/DLCEncoderTests/SingleValueContainerTests.swift +++ b/Tests/DLCEncoderTests/SingleValueContainerTests.swift @@ -138,7 +138,7 @@ final class SingleValueContainerTests: XCTestCase { } private extension SingleValueContainerTests { - enum RawRepresentableModel: String, Encodable, SQLiteRawRepresentable { + enum RawRepresentableModel: String, Encodable, SQLiteRepresentable { case test } @@ -159,13 +159,13 @@ private extension SingleValueContainerTests { } final class MockSingleValueEncoder: ValueEncoder { - private(set) var sqliteData: SQLiteRawValue? + private(set) var sqliteData: SQLiteValue? let dateEncoder: any DateEncoder let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey: Any] init( - sqliteData: SQLiteRawValue? = nil, + sqliteData: SQLiteValue? = nil, dateEncoder: any DateEncoder = MockDateEncoder(), codingPath: [any CodingKey] = [], userInfo: [CodingUserInfoKey: Any] = [:] @@ -184,8 +184,8 @@ private extension SingleValueContainerTests { try dateEncoder.encode(date, to: self) } - func encode(_ value: T) throws { - sqliteData = value.sqliteRawValue + func encode(_ value: T) throws { + sqliteData = value.sqliteValue } func container( diff --git a/Tests/DLCEncoderTests/SingleValueEncoderTests.swift b/Tests/DLCEncoderTests/SingleValueEncoderTests.swift index 3352888..641b666 100644 --- a/Tests/DLCEncoderTests/SingleValueEncoderTests.swift +++ b/Tests/DLCEncoderTests/SingleValueEncoderTests.swift @@ -24,7 +24,7 @@ final class SingleValueEncoderTests: XCTestCase { userInfo: [:] ) try encoder.encodeDate(date) - XCTAssertEqual(encoder.sqliteData, date.sqliteRawValue) + XCTAssertEqual(encoder.sqliteData, date.sqliteValue) XCTAssertTrue(dateEncoder.didCallEncode) } diff --git a/Tests/DLCEncoderTests/UnkeyedContainerTests.swift b/Tests/DLCEncoderTests/UnkeyedContainerTests.swift index e593217..613f913 100644 --- a/Tests/DLCEncoderTests/UnkeyedContainerTests.swift +++ b/Tests/DLCEncoderTests/UnkeyedContainerTests.swift @@ -145,7 +145,7 @@ private extension UnkeyedContainerTests { fatalError() } - func encode(_ value: T, for key: any CodingKey) throws { + func encode(_ value: T, for key: any CodingKey) throws { fatalError() } @@ -188,7 +188,7 @@ private extension UnkeyedContainerTests { } func set(_ value: Any, for key: any CodingKey) throws { - guard let value = value as? SQLiteRawValue else { + guard let value = value as? SQLiteValue else { fatalError() } sqliteData[key.stringValue] = value @@ -202,8 +202,8 @@ private extension UnkeyedContainerTests { try dateEncoder.encode(date, for: key, to: self) } - func encode(_ value: T, for key: any CodingKey) throws { - sqliteData[key.stringValue] = value.sqliteRawValue + func encode(_ value: T, for key: any CodingKey) throws { + sqliteData[key.stringValue] = value.sqliteValue } func encoder(for key: any CodingKey) throws -> any Encoder { @@ -254,7 +254,7 @@ private extension UnkeyedContainerTests { switch value { case let value as Date: try encoder.encodeDate(value, for: key) - case let value as SQLiteRawRepresentable: + case let value as SQLiteRepresentable: try encoder.encode(value, for: key) default: let valueEncoder = try encoder.encoder(for: key) diff --git a/Tests/DataLiteCoderTests/DateDecoderTests.swift b/Tests/DataLiteCoderTests/DateDecoderTests.swift index 66ca297..608b636 100644 --- a/Tests/DataLiteCoderTests/DateDecoderTests.swift +++ b/Tests/DataLiteCoderTests/DateDecoderTests.swift @@ -137,13 +137,13 @@ private extension DateDecoderTests { } final class SingleValueDecoder: DLCDecoder.ValueDecoder { - let sqliteData: SQLiteRawValue + let sqliteData: SQLiteValue let dateDecoder: DLCDecoder.DateDecoder let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey: Any] init( - sqliteData: SQLiteRawValue, + sqliteData: SQLiteValue, dateDecoder: DLCDecoder.DateDecoder = RowDecoder.DateDecoder(strategy: .deferredToDate), codingPath: [any CodingKey] = [], userInfo: [CodingUserInfoKey: Any] = [:] @@ -162,7 +162,7 @@ private extension DateDecoderTests { fatalError() } - func decode(_ type: T.Type) throws -> T { + func decode(_ type: T.Type) throws -> T { type.init(sqliteData)! } @@ -213,7 +213,7 @@ private extension DateDecoderTests { fatalError() } - func decode( + func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { diff --git a/Tests/DataLiteCoderTests/DateEncoderTests.swift b/Tests/DataLiteCoderTests/DateEncoderTests.swift index 2485b7f..28b02d1 100644 --- a/Tests/DataLiteCoderTests/DateEncoderTests.swift +++ b/Tests/DataLiteCoderTests/DateEncoderTests.swift @@ -17,8 +17,8 @@ final class DateEncoderTests: XCTestCase { try dateEncoder.encode(date, to: singleEncoder) try dateEncoder.encode(date, for: key, to: keyedEncoder) - XCTAssertEqual(singleEncoder.sqliteData, date.sqliteRawValue) - XCTAssertEqual(keyedEncoder.sqliteData[key], date.sqliteRawValue) + XCTAssertEqual(singleEncoder.sqliteData, date.sqliteValue) + XCTAssertEqual(keyedEncoder.sqliteData[key], date.sqliteValue) } func testISO8601() throws { @@ -127,7 +127,7 @@ private extension DateEncoderTests { let codingPath: [any CodingKey] let userInfo: [CodingUserInfoKey : Any] - private(set) var sqliteData: SQLiteRawValue? + private(set) var sqliteData: SQLiteValue? init( dateEncoder: any DateEncoder, @@ -147,8 +147,8 @@ private extension DateEncoderTests { fatalError() } - func encode(_ value: T) throws { - sqliteData = value.sqliteRawValue + func encode(_ value: T) throws { + sqliteData = value.sqliteValue } func container( @@ -197,8 +197,8 @@ private extension DateEncoderTests { fatalError() } - func encode(_ value: T, for key: any CodingKey) throws { - sqliteData[key] = value.sqliteRawValue + func encode(_ value: T, for key: any CodingKey) throws { + sqliteData[key] = value.sqliteValue } func encoder(for key: any CodingKey) throws -> any Encoder { diff --git a/Tests/DataLiteCoderTests/RowDecoderTests.swift b/Tests/DataLiteCoderTests/RowDecoderTests.swift index d5680c9..32b3651 100644 --- a/Tests/DataLiteCoderTests/RowDecoderTests.swift +++ b/Tests/DataLiteCoderTests/RowDecoderTests.swift @@ -23,14 +23,14 @@ final class RowDecoderTests: XCTestCase { ) var row = SQLiteRow() - row["id"] = model.id.sqliteRawValue - row["type"] = model.type.rawValue.sqliteRawValue - row["name"] = model.name.sqliteRawValue - row["age"] = model.age.sqliteRawValue - row["isActive"] = model.isActive.sqliteRawValue - row["score"] = model.score.sqliteRawValue - row["createdAt"] = model.createdAt.sqliteRawValue - row["payload"] = model.payload.sqliteRawValue + row["id"] = model.id.sqliteValue + row["type"] = model.type.rawValue.sqliteValue + row["name"] = model.name.sqliteValue + row["age"] = model.age.sqliteValue + row["isActive"] = model.isActive.sqliteValue + row["score"] = model.score.sqliteValue + row["createdAt"] = model.createdAt.sqliteValue + row["payload"] = model.payload.sqliteValue let decoded = try decoder.decode( StandardModel.self, @@ -55,11 +55,11 @@ final class RowDecoderTests: XCTestCase { ) var row = SQLiteRow() - row["id"] = model.id!.sqliteRawValue - row["type"] = model.type!.rawValue.sqliteRawValue - row["name"] = model.name!.sqliteRawValue - row["createdAt"] = model.createdAt!.sqliteRawValue - row["payload"] = model.payload!.sqliteRawValue + row["id"] = model.id!.sqliteValue + row["type"] = model.type!.rawValue.sqliteValue + row["name"] = model.name!.sqliteValue + row["createdAt"] = model.createdAt!.sqliteValue + row["payload"] = model.payload!.sqliteValue let decoded = try decoder.decode( OptionalModel.self, @@ -88,9 +88,9 @@ final class RowDecoderTests: XCTestCase { ] var row = SQLiteRow() - row["key0"] = dates[0].sqliteRawValue - row["key1"] = dates[1].sqliteRawValue - row["key2"] = dates[2].sqliteRawValue + row["key0"] = dates[0].sqliteValue + row["key1"] = dates[1].sqliteValue + row["key2"] = dates[2].sqliteValue let decoded = try decoder.decode([Date].self, from: row) @@ -104,7 +104,7 @@ final class RowDecoderTests: XCTestCase { ) var row = SQLiteRow() - row["id"] = 1.sqliteRawValue + row["id"] = 1.sqliteValue XCTAssertThrowsError( try decoder.decode(SimpleModel.self, from: row) @@ -122,8 +122,8 @@ final class RowDecoderTests: XCTestCase { ) var row = SQLiteRow() - row["id"] = "not an int".sqliteRawValue - row["name"] = "test".sqliteRawValue + row["id"] = "not an int".sqliteValue + row["name"] = "test".sqliteValue XCTAssertThrowsError( try decoder.decode(SimpleModel.self, from: row) @@ -167,14 +167,14 @@ final class RowDecoderTests: XCTestCase { let rows: [SQLiteRow] = models.map { model in var row = SQLiteRow() - row["id"] = model.id.sqliteRawValue - row["type"] = model.type.rawValue.sqliteRawValue - row["name"] = model.name.sqliteRawValue - row["age"] = model.age.sqliteRawValue - row["isActive"] = model.isActive.sqliteRawValue - row["score"] = model.score.sqliteRawValue - row["createdAt"] = model.createdAt.sqliteRawValue - row["payload"] = model.payload.sqliteRawValue + row["id"] = model.id.sqliteValue + row["type"] = model.type.rawValue.sqliteValue + row["name"] = model.name.sqliteValue + row["age"] = model.age.sqliteValue + row["isActive"] = model.isActive.sqliteValue + row["score"] = model.score.sqliteValue + row["createdAt"] = model.createdAt.sqliteValue + row["payload"] = model.payload.sqliteValue return row } @@ -208,11 +208,11 @@ final class RowDecoderTests: XCTestCase { let rows: [SQLiteRow] = models.map { model in var row = SQLiteRow() - row["id"] = model.id?.sqliteRawValue - row["type"] = model.type?.rawValue.sqliteRawValue - row["name"] = model.name?.sqliteRawValue - row["createdAt"] = model.createdAt?.sqliteRawValue - row["payload"] = model.payload?.sqliteRawValue + row["id"] = model.id?.sqliteValue + row["type"] = model.type?.rawValue.sqliteValue + row["name"] = model.name?.sqliteValue + row["createdAt"] = model.createdAt?.sqliteValue + row["payload"] = model.payload?.sqliteValue return row } @@ -242,9 +242,9 @@ final class RowDecoderTests: XCTestCase { let rows: [SQLiteRow] = dates.map { dates in var row = SQLiteRow() - row["key0"] = dates[0].sqliteRawValue - row["key1"] = dates[1].sqliteRawValue - row["key2"] = dates[2].sqliteRawValue + row["key0"] = dates[0].sqliteValue + row["key1"] = dates[1].sqliteValue + row["key2"] = dates[2].sqliteValue return row } @@ -260,7 +260,7 @@ final class RowDecoderTests: XCTestCase { ) var row = SQLiteRow() - row["id"] = 1.sqliteRawValue + row["id"] = 1.sqliteValue XCTAssertThrowsError( try decoder.decode([SimpleModel].self, from: [row]) @@ -278,8 +278,8 @@ final class RowDecoderTests: XCTestCase { ) var row = SQLiteRow() - row["id"] = "not an int".sqliteRawValue - row["name"] = "test".sqliteRawValue + row["id"] = "not an int".sqliteValue + row["name"] = "test".sqliteValue XCTAssertThrowsError( try decoder.decode([SimpleModel].self, from: [row]) diff --git a/Tests/DataLiteCoderTests/RowEncoderTests.swift b/Tests/DataLiteCoderTests/RowEncoderTests.swift index 2e4ce2d..f5693dc 100644 --- a/Tests/DataLiteCoderTests/RowEncoderTests.swift +++ b/Tests/DataLiteCoderTests/RowEncoderTests.swift @@ -31,7 +31,7 @@ final class RowEncoderTests: XCTestCase { XCTAssertEqual(row["age"], .int(34)) XCTAssertEqual(row["isActive"], .int(1)) XCTAssertEqual(row["score"], .real(3.1415)) - XCTAssertEqual(row["createdAt"], createdAt.sqliteRawValue) + XCTAssertEqual(row["createdAt"], createdAt.sqliteValue) XCTAssertEqual(row["payload"], .blob(payload)) } @@ -55,7 +55,7 @@ final class RowEncoderTests: XCTestCase { XCTAssertEqual(row["id"], .int(123456)) XCTAssertEqual(row["type"], .text("multiple")) XCTAssertEqual(row["name"], .text("Jane Doe")) - XCTAssertEqual(row["createdAt"], createdAt.sqliteRawValue) + XCTAssertEqual(row["createdAt"], createdAt.sqliteValue) XCTAssertEqual(row["payload"], .blob(payload)) } @@ -116,7 +116,7 @@ final class RowEncoderTests: XCTestCase { XCTAssertEqual(rows[0]["age"], .int(34)) XCTAssertEqual(rows[0]["isActive"], .int(1)) XCTAssertEqual(rows[0]["score"], .real(3.1415)) - XCTAssertEqual(rows[0]["createdAt"], createdAt.sqliteRawValue) + XCTAssertEqual(rows[0]["createdAt"], createdAt.sqliteValue) XCTAssertEqual(rows[0]["payload"], .blob(payload)) XCTAssertEqual(rows[1]["id"], .int(456)) @@ -125,7 +125,7 @@ final class RowEncoderTests: XCTestCase { XCTAssertEqual(rows[1]["age"], .int(28)) XCTAssertEqual(rows[1]["isActive"], .int(0)) XCTAssertEqual(rows[1]["score"], .real(2.7182)) - XCTAssertEqual(rows[1]["createdAt"], createdAt.sqliteRawValue) + XCTAssertEqual(rows[1]["createdAt"], createdAt.sqliteValue) XCTAssertEqual(rows[1]["payload"], .blob(payload)) } @@ -162,7 +162,7 @@ final class RowEncoderTests: XCTestCase { XCTAssertEqual(rows[0]["id"], .int(123)) XCTAssertEqual(rows[0]["type"], .text("multiple")) XCTAssertEqual(rows[0]["name"], .text("Jane Doe")) - XCTAssertEqual(rows[0]["createdAt"], createdAt.sqliteRawValue) + XCTAssertEqual(rows[0]["createdAt"], createdAt.sqliteValue) XCTAssertEqual(rows[0]["payload"], .blob(payload)) XCTAssertEqual(rows[1]["id"], .null)