Update dependencies

This commit is contained in:
2025-10-24 20:16:30 +03:00
parent 4fa72e8065
commit 9c6a81437c
33 changed files with 122 additions and 122 deletions

View File

@@ -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")
],

View File

@@ -34,7 +34,7 @@ final class KeyedContainer<Decoder: RowDecoder & KeyCheckingDecoder, Key: Coding
switch type {
case is Date.Type:
try decoder.decodeDate(for: key) as! T
case let type as SQLiteRawRepresentable.Type:
case let type as SQLiteRepresentable.Type:
try decoder.decode(type, for: key) as! T
default:
try T(from: decoder.decoder(for: key))

View File

@@ -40,7 +40,7 @@ public final class MultiRowDecoder: RowDecoder {
return try decode(Date.self, for: key)
}
public func decode<T: SQLiteRawRepresentable>(
public func decode<T: SQLiteRepresentable>(
_ type: T.Type,
for key: any CodingKey
) throws -> T {

View File

@@ -49,7 +49,7 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder {
try dateDecoder.decode(from: self, for: key)
}
public func decode<T: SQLiteRawRepresentable>(
public func decode<T: SQLiteRepresentable>(
_ type: T.Type,
for key: any CodingKey
) throws -> T {

View File

@@ -27,7 +27,7 @@ final class SingleValueContainer<Decoder: ValueDecoder>: 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)

View File

@@ -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<T: SQLiteRawRepresentable>(_ type: T.Type) throws -> T {
func decode<T: SQLiteRepresentable>(_ 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(

View File

@@ -52,7 +52,7 @@ final class UnkeyedContainer<Decoder: RowDecoder>: 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))

View File

@@ -6,6 +6,6 @@ public protocol RowDecoder: Decoder {
func decodeNil(for key: CodingKey) throws -> Bool
func decodeDate(for key: CodingKey) throws -> Date
func decode<T: SQLiteRawRepresentable>(_ type: T.Type, for key: CodingKey) throws -> T
func decode<T: SQLiteRepresentable>(_ type: T.Type, for key: CodingKey) throws -> T
func decoder(for key: CodingKey) throws -> any Decoder
}

View File

@@ -4,5 +4,5 @@ import DataLiteCore
public protocol ValueDecoder: Decoder {
func decodeNil() -> Bool
func decodeDate() throws -> Date
func decode<T: SQLiteRawRepresentable>(_ type: T.Type) throws -> T
func decode<T: SQLiteRepresentable>(_ type: T.Type) throws -> T
}

View File

@@ -29,7 +29,7 @@ final class KeyedContainer<Encoder: RowEncoder, Key: CodingKey>: 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)

View File

@@ -59,7 +59,7 @@ public final class MultiRowEncoder: RowEncoder {
throw EncodingError.invalidValue(date, context)
}
public func encode<T: SQLiteRawBindable>(_ value: T, for key: any CodingKey) throws {
public func encode<T: SQLiteBindable>(_ 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],

View File

@@ -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<T: SQLiteRawBindable>(_ value: T, for key: any CodingKey) throws {
sqliteData[key] = value.sqliteRawValue
public func encode<T: SQLiteBindable>(_ value: T, for key: any CodingKey) throws {
sqliteData[key] = value.sqliteValue
}
public func encoder(for key: any CodingKey) throws -> any Encoder {

View File

@@ -27,7 +27,7 @@ final class SingleValueContainer<Encoder: ValueEncoder>: 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)

View File

@@ -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<T: SQLiteRawBindable>(_ value: T) throws {
sqliteData = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ value: T) throws {
sqliteData = value.sqliteValue
}
func container<Key: CodingKey>(

View File

@@ -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<T: SQLiteRawBindable>(_ value: T, for key: CodingKey) throws
func encode<T: SQLiteBindable>(_ value: T, for key: CodingKey) throws
func encoder(for key: CodingKey) throws -> any Encoder
}

View File

@@ -4,5 +4,5 @@ import DataLiteCore
public protocol ValueEncoder: Encoder {
func encodeNil() throws
func encodeDate(_ date: Date) throws
func encode<T: SQLiteRawBindable>(_ value: T) throws
func encode<T: SQLiteBindable>(_ value: T) throws
}

View File

@@ -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

View File

@@ -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 types conformance to `SQLiteRawRepresentable`
/// This strategy relies on the types conformance to `SQLiteRepresentable`
/// to decode the date value from SQLite data.
case deferredToDate

View File

@@ -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 types conformance to `SQLiteRawRepresentable`
/// This strategy relies on the types conformance to `SQLiteRepresentable`
/// to encode the date value into a SQLite-compatible representation.
case deferredToDate

View File

@@ -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<T: SQLiteRawRepresentable>(
func decode<T: SQLiteRepresentable>(
_ 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<T: SQLiteRawRepresentable>(
func decode<T: SQLiteRepresentable>(
_ type: T.Type
) throws -> T {
fatalError()

View File

@@ -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.")
}
}

View File

@@ -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<T: SQLiteRawRepresentable>(
func decode<T: SQLiteRepresentable>(
_ type: T.Type
) throws -> T {
type.init(sqliteData)!

View File

@@ -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(

View File

@@ -488,7 +488,7 @@ final class UnkeyedContainerTests: XCTestCase {
private extension UnkeyedContainerTests {
func container(
withData data: SQLiteRawValue,
withData data: SQLiteValue,
codingPath: [any CodingKey] = []
) -> UnkeyedContainer<MockKeyedDecoder> {
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<T: SQLiteRawRepresentable>(
func decode<T: SQLiteRepresentable>(
_ 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<T: SQLiteRawRepresentable>(
func decode<T: SQLiteRepresentable>(
_ type: T.Type
) throws -> T {
fatalError()

View File

@@ -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<T: SQLiteRawBindable>(_ value: T, for key: any CodingKey) throws {
sqliteData[key.stringValue] = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ 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<T: SQLiteRawBindable>(_ value: T) throws {
sqliteData = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ value: T) throws {
sqliteData = value.sqliteValue
}
func container<Key: CodingKey>(
@@ -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)

View File

@@ -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)
}

View File

@@ -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<T: SQLiteRawBindable>(_ value: T) throws {
sqliteData = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ value: T) throws {
sqliteData = value.sqliteValue
}
func container<Key: CodingKey>(

View File

@@ -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)
}

View File

@@ -145,7 +145,7 @@ private extension UnkeyedContainerTests {
fatalError()
}
func encode<T: SQLiteRawBindable>(_ value: T, for key: any CodingKey) throws {
func encode<T: SQLiteBindable>(_ 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<T: SQLiteRawBindable>(_ value: T, for key: any CodingKey) throws {
sqliteData[key.stringValue] = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ 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)

View File

@@ -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<T: SQLiteRawRepresentable>(_ type: T.Type) throws -> T {
func decode<T: SQLiteRepresentable>(_ type: T.Type) throws -> T {
type.init(sqliteData)!
}
@@ -213,7 +213,7 @@ private extension DateDecoderTests {
fatalError()
}
func decode<T: SQLiteRawRepresentable>(
func decode<T: SQLiteRepresentable>(
_ type: T.Type,
for key: any CodingKey
) throws -> T {

View File

@@ -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<T: SQLiteRawBindable>(_ value: T) throws {
sqliteData = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ value: T) throws {
sqliteData = value.sqliteValue
}
func container<Key: CodingKey>(
@@ -197,8 +197,8 @@ private extension DateEncoderTests {
fatalError()
}
func encode<T: SQLiteRawBindable>(_ value: T, for key: any CodingKey) throws {
sqliteData[key] = value.sqliteRawValue
func encode<T: SQLiteBindable>(_ value: T, for key: any CodingKey) throws {
sqliteData[key] = value.sqliteValue
}
func encoder(for key: any CodingKey) throws -> any Encoder {

View File

@@ -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])

View File

@@ -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)