mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Enhance DocC output for ForeignKeyViolation
This commit is contained in:
1 parent
fb81ec6792
commit
754ced7b5e
1 file changed
+34
-30
@@ -984,7 +984,7 @@ public struct IndexInfo {
|
||||
/// ```
|
||||
///
|
||||
/// Related SQLite documentation: <https://www.sqlite.org/pragma.html#pragma_foreign_key_check>
|
||||
public struct ForeignKeyViolation: FetchableRecord, CustomStringConvertible {
|
||||
public struct ForeignKeyViolation {
|
||||
/// The name of the table that contains the foreign key.
|
||||
public var originTable: String
|
||||
|
||||
@@ -1002,35 +1002,6 @@ public struct ForeignKeyViolation: FetchableRecord, CustomStringConvertible {
|
||||
/// ``ForeignKeyInfo``. See ``Database/foreignKeys(on:)``.
|
||||
public var foreignKeyId: Int
|
||||
|
||||
public init(row: Row) {
|
||||
originTable = row[0]
|
||||
originRowID = row[1]
|
||||
destinationTable = row[2]
|
||||
foreignKeyId = row[3]
|
||||
}
|
||||
|
||||
/// A description of the foreign key violation.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```
|
||||
/// FOREIGN KEY constraint violation - from player to team, in rowid 1
|
||||
/// ```
|
||||
///
|
||||
/// See also ``failureDescription(_:)``.
|
||||
public var description: String {
|
||||
if let originRowID = originRowID {
|
||||
return """
|
||||
FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable), \
|
||||
in rowid \(originRowID)
|
||||
"""
|
||||
} else {
|
||||
return """
|
||||
FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable)
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
/// A precise description of the foreign key violation.
|
||||
///
|
||||
/// For example:
|
||||
@@ -1083,6 +1054,39 @@ public struct ForeignKeyViolation: FetchableRecord, CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
extension ForeignKeyViolation: FetchableRecord {
|
||||
public init(row: Row) {
|
||||
originTable = row[0]
|
||||
originRowID = row[1]
|
||||
destinationTable = row[2]
|
||||
foreignKeyId = row[3]
|
||||
}
|
||||
}
|
||||
|
||||
extension ForeignKeyViolation: CustomStringConvertible {
|
||||
/// A description of the foreign key violation.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```
|
||||
/// FOREIGN KEY constraint violation - from player to team, in rowid 1
|
||||
/// ```
|
||||
///
|
||||
/// See also ``failureDescription(_:)``.
|
||||
public var description: String {
|
||||
if let originRowID = originRowID {
|
||||
return """
|
||||
FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable), \
|
||||
in rowid \(originRowID)
|
||||
"""
|
||||
} else {
|
||||
return """
|
||||
FOREIGN KEY constraint violation - from \(originTable) to \(destinationTable)
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a primary key.
|
||||
///
|
||||
/// You get `PrimaryKeyInfo` instances with the ``Database/primaryKey(_:)``
|
||||
|
||||
Reference in new issue
Block a user