@@ -984,7 +984,7 @@ public struct IndexInfo {
984
984
/// ```
985
985
///
986
986
/// Related SQLite documentation: <https://www.sqlite.org/pragma.html#pragma_foreign_key_check>
987
- public struct ForeignKeyViolation : FetchableRecord , CustomStringConvertible {
987
+ public struct ForeignKeyViolation {
988
988
/// The name of the table that contains the foreign key.
989
989
public var originTable : String
990
990
@@ -1002,35 +1002,6 @@ public struct ForeignKeyViolation: FetchableRecord, CustomStringConvertible {
1002
1002
/// ``ForeignKeyInfo``. See ``Database/foreignKeys(on:)``.
1003
1003
public var foreignKeyId : Int
1004
1004
1005
- public init ( row: Row ) {
1006
- originTable = row [ 0 ]
1007
- originRowID = row [ 1 ]
1008
- destinationTable = row [ 2 ]
1009
- foreignKeyId = row [ 3 ]
1010
- }
1011
-
1012
- /// A description of the foreign key violation.
1013
- ///
1014
- /// For example:
1015
- ///
1016
- /// ```
1017
- /// FOREIGN KEY constraint violation - from player to team, in rowid 1
1018
- /// ```
1019
- ///
1020
- /// See also ``failureDescription(_:)``.
1021
- public var description : String {
1022
- if let originRowID = originRowID {
1023
- return """
1024
- FOREIGN KEY constraint violation - from \( originTable) to \( destinationTable) , \
1025
- in rowid \( originRowID)
1026
- """
1027
- } else {
1028
- return """
1029
- FOREIGN KEY constraint violation - from \( originTable) to \( destinationTable)
1030
- """
1031
- }
1032
- }
1033
-
1034
1005
/// A precise description of the foreign key violation.
1035
1006
///
1036
1007
/// For example:
@@ -1083,6 +1054,39 @@ public struct ForeignKeyViolation: FetchableRecord, CustomStringConvertible {
1083
1054
}
1084
1055
}
1085
1056
1057
+ extension ForeignKeyViolation : FetchableRecord {
1058
+ public init ( row: Row ) {
1059
+ originTable = row [ 0 ]
1060
+ originRowID = row [ 1 ]
1061
+ destinationTable = row [ 2 ]
1062
+ foreignKeyId = row [ 3 ]
1063
+ }
1064
+ }
1065
+
1066
+ extension ForeignKeyViolation : CustomStringConvertible {
1067
+ /// A description of the foreign key violation.
1068
+ ///
1069
+ /// For example:
1070
+ ///
1071
+ /// ```
1072
+ /// FOREIGN KEY constraint violation - from player to team, in rowid 1
1073
+ /// ```
1074
+ ///
1075
+ /// See also ``failureDescription(_:)``.
1076
+ public var description : String {
1077
+ if let originRowID = originRowID {
1078
+ return """
1079
+ FOREIGN KEY constraint violation - from \( originTable) to \( destinationTable) , \
1080
+ in rowid \( originRowID)
1081
+ """
1082
+ } else {
1083
+ return """
1084
+ FOREIGN KEY constraint violation - from \( originTable) to \( destinationTable)
1085
+ """
1086
+ }
1087
+ }
1088
+ }
1089
+
1086
1090
/// Information about a primary key.
1087
1091
///
1088
1092
/// You get `PrimaryKeyInfo` instances with the ``Database/primaryKey(_:)``
0 commit comments