Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/LSQLite/Database/Database+Authorizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension Database {
case .ok: "ok"
case .deny: "deny"
case .ignore: "ignore"
default: rawValue.description
default: "unknown"
}
}

Expand Down Expand Up @@ -182,7 +182,7 @@ extension Database {
case .savepoint: "savepoint"
case .copy: "copy"
case .recursive: "recursive"
default: rawValue.description
default: "unknown"
}
}

Expand Down
17 changes: 9 additions & 8 deletions Sources/LSQLite/Database/Database+Busy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension Database {
/// Result codes a busy handler can return to retry or abort.
///
/// Related SQLite: `sqlite3_busy_handler`, `sqlite3_busy_timeout`, `SQLITE_BUSY`
@frozen public struct BusyHandlerResult: Hashable, RawRepresentable, CustomDebugStringConvertible {
@frozen public struct BusyHandlerResult: Hashable, RawRepresentable, CustomStringConvertible, CustomDebugStringConvertible {
public let rawValue: Int32

@inlinable public init(rawValue: Int32) {
Expand All @@ -19,16 +19,17 @@ extension Database {
public static let `break` = Self(rawValue: 0)
public static let `continue` = Self(rawValue: 1)

/// Debug label for the busy handler response.
///
/// Related SQLite: `sqlite3_busy_handler`, `SQLITE_BUSY`
public var debugDescription: String {
public var description: String {
switch self {
case .break: return "LSQLITE_BREAK"
case .continue: return "LSQLITE_CONTINUE"
default: return "BusyHandlerResult(rawValue: \(rawValue))"
case .break: "break"
case .continue: "continue"
default: "unknown"
}
}

public var debugDescription: String {
"\(description) (\(rawValue.description))"
}
}

/// Registers a busy handler invoked when this connection hits `SQLITE_BUSY`; return `.continue` to retry or `.break` to stop.
Expand Down
25 changes: 16 additions & 9 deletions Sources/LSQLite/Database/Database+Checkpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extension Database {
/// WAL checkpoint modes used by `walCheckpoint(_:mode:frameCount:totalFrameCount:)` and auto-checkpointing.
///
/// Related SQLite: `SQLITE_CHECKPOINT_PASSIVE`, `SQLITE_CHECKPOINT_FULL`, `SQLITE_CHECKPOINT_RESTART`, `SQLITE_CHECKPOINT_TRUNCATE`
@frozen public struct CheckpointMode: Hashable, RawRepresentable, CustomDebugStringConvertible {
@frozen public struct CheckpointMode: Hashable, RawRepresentable, CustomStringConvertible, CustomDebugStringConvertible {
public let rawValue: Int32

@inlinable public init(rawValue: Int32) {
Expand All @@ -16,16 +16,23 @@ extension Database {
public static let restart = Self(rawValue: SQLITE_CHECKPOINT_RESTART)
public static let truncate = Self(rawValue: SQLITE_CHECKPOINT_TRUNCATE)

/// Debug label for the checkpoint mode.
///
/// Related SQLite: `SQLITE_CHECKPOINT_PASSIVE`, `SQLITE_CHECKPOINT_FULL`, `SQLITE_CHECKPOINT_RESTART`, `SQLITE_CHECKPOINT_TRUNCATE`
public var description: String {
switch self {
case .passive: "passive"
case .full: "full"
case .restart: "restart"
case .truncate: "truncate"
default: "unknown"
}
}

public var debugDescription: String {
switch self {
case .passive: return "SQLITE_CHECKPOINT_PASSIVE"
case .full: return "SQLITE_CHECKPOINT_FULL"
case .restart: return "SQLITE_CHECKPOINT_RESTART"
case .truncate: return "SQLITE_CHECKPOINT_TRUNCATE"
default: return "CheckpointMode(rawValue: \(rawValue))"
case .passive: "SQLITE_CHECKPOINT_PASSIVE"
case .full: "SQLITE_CHECKPOINT_FULL"
case .restart: "SQLITE_CHECKPOINT_RESTART"
case .truncate: "SQLITE_CHECKPOINT_TRUNCATE"
default: rawValue.description
}
}
}
Expand Down
28 changes: 17 additions & 11 deletions Sources/LSQLite/Database/Database+Collation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Database {
/// Text encoding and behavior flags for user-defined collations.
///
/// Related SQLite: `sqlite3_create_collation_v2`, `SQLITE_UTF8`, `SQLITE_UTF16LE`, `SQLITE_UTF16BE`, `SQLITE_UTF16`, `SQLITE_UTF16_ALIGNED`, `SQLITE_DETERMINISTIC`
@frozen public struct CollationFlag: Hashable, RawRepresentable, CustomDebugStringConvertible {
@frozen public struct CollationFlag: Hashable, RawRepresentable, CustomStringConvertible, CustomDebugStringConvertible {
public let rawValue: Int32

@inlinable public init(rawValue: Int32) {
Expand All @@ -32,19 +32,25 @@ extension Database {
public static let utf16 = Self(rawValue: SQLITE_UTF16)
public static let utf16Aligned = Self(rawValue: SQLITE_UTF16_ALIGNED)

public static let deterministic = Self(rawValue: SQLITE_DETERMINISTIC)
public var description: String {
switch self {
case .utf8: "utf8"
case .utf16le: "utf16le"
case .utf16be: "utf16be"
case .utf16: "utf16"
case .utf16Aligned: "utf16Aligned"
default: "unknown"
}
}

/// Debug label for the collation flag.
///
/// Related SQLite: `sqlite3_create_collation_v2`, `SQLITE_UTF8`, `SQLITE_UTF16LE`, `SQLITE_UTF16BE`, `SQLITE_UTF16`, `SQLITE_UTF16_ALIGNED`, `SQLITE_DETERMINISTIC`
public var debugDescription: String {
switch self {
case .utf8: return "SQLITE_UTF8"
case .utf16le: return "SQLITE_UTF16LE"
case .utf16be: return "SQLITE_UTF16BE"
case .utf16: return "SQLITE_UTF16"
case .utf16Aligned: return "SQLITE_UTF16_ALIGNED"
default: return "FunctionFlag(rawValue: \(rawValue))"
case .utf8: "SQLITE_UTF8"
case .utf16le: "SQLITE_UTF16LE"
case .utf16be: "SQLITE_UTF16BE"
case .utf16: "SQLITE_UTF16"
case .utf16Aligned: "SQLITE_UTF16_ALIGNED"
default: rawValue.description
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions Sources/LSQLite/Database/Database+Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extension Database {
/// Switch controlling whether extended result codes are reported for this connection.
///
/// Related SQLite: `sqlite3_extended_result_codes`
@frozen public struct ExtendedResultCodeStatus: Hashable, RawRepresentable, CustomDebugStringConvertible {
@frozen public struct ExtendedResultCodeStatus: Hashable, RawRepresentable, CustomStringConvertible, CustomDebugStringConvertible {
public let rawValue: Int32

@inlinable public init(rawValue: Int32) {
Expand All @@ -14,16 +14,17 @@ extension Database {
public static let off = Self(rawValue: 0)
public static let on = Self(rawValue: 1)

/// Debug label for the extended result code toggle.
///
/// Related SQLite: `sqlite3_extended_result_codes`
public var debugDescription: String {
public var description: String {
switch self {
case .off: return "LSQLITE_OFF"
case .on: return "LSQLITE_ON"
default: return "ExtendedResultCodeStatus(rawValue: \(rawValue))"
case .off: "off"
case .on: "on"
default: "unknown"
}
}

public var debugDescription: String {
"\(description) (\(rawValue.description))"
}
}

/// Last result code set by an API call on this connection.
Expand Down
17 changes: 9 additions & 8 deletions Sources/LSQLite/Database/Database+Exec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension Database {
/// Return codes for `ExecCallback` indicating whether to continue or abort execution.
///
/// Related SQLite: `sqlite3_exec`
@frozen public struct ExecCallbackResult: Hashable, RawRepresentable, CustomDebugStringConvertible {
@frozen public struct ExecCallbackResult: Hashable, RawRepresentable, CustomStringConvertible, CustomDebugStringConvertible {
public let rawValue: Int32

@inlinable public init(rawValue: Int32) {
Expand All @@ -19,16 +19,17 @@ extension Database {
public static let `continue` = Self(rawValue: 0)
public static let abort = Self(rawValue: 1)

/// Debug label for the exec callback result.
///
/// Related SQLite: `sqlite3_exec`
public var debugDescription: String {
public var description: String {
switch self {
case .continue: return "LSQLITE_CONTINUE"
case .abort: return "LSQLITE_ABORT"
default: return "ExecCallbackResult(rawValue: \(rawValue))"
case .continue: "continue"
case .abort: "abort"
default: "unknown"
}
}

public var debugDescription: String {
"\(description) (\(rawValue.description))"
}
}

/// Executes one or more semicolon-separated SQL statements with an optional row callback.
Expand Down
Loading