Update dependencies
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>(
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user