@@ -47,6 +47,10 @@ pub enum Error {
47
47
/// for [`query_row`](crate::Connection::query_row)) did not return any.
48
48
QueryReturnedNoRows ,
49
49
50
+ /// Error when a query that was expected to return only one row (e.g.,
51
+ /// for [`query_one`](crate::Connection::query_one)) did return more than one.
52
+ QueryReturnedMoreThanOneRow ,
53
+
50
54
/// Error when the value of a particular column is requested, but the index
51
55
/// is out of range for the statement.
52
56
InvalidColumnIndex ( usize ) ,
@@ -96,6 +100,7 @@ impl PartialEq for Error {
96
100
( Self :: InvalidPath ( p1) , Self :: InvalidPath ( p2) ) => p1 == p2,
97
101
( Self :: ExecuteReturnedResults , Self :: ExecuteReturnedResults ) => true ,
98
102
( Self :: QueryReturnedNoRows , Self :: QueryReturnedNoRows ) => true ,
103
+ ( Self :: QueryReturnedMoreThanOneRow , Self :: QueryReturnedMoreThanOneRow ) => true ,
99
104
( Self :: InvalidColumnIndex ( i1) , Self :: InvalidColumnIndex ( i2) ) => i1 == i2,
100
105
( Self :: InvalidColumnName ( n1) , Self :: InvalidColumnName ( n2) ) => n1 == n2,
101
106
( Self :: InvalidColumnType ( i1, n1, t1) , Self :: InvalidColumnType ( i2, n2, t2) ) => {
@@ -170,6 +175,7 @@ impl fmt::Display for Error {
170
175
write ! ( f, "Execute returned results - did you mean to call query?" )
171
176
}
172
177
Self :: QueryReturnedNoRows => write ! ( f, "Query returned no rows" ) ,
178
+ Self :: QueryReturnedMoreThanOneRow => write ! ( f, "Query returned more than one row" ) ,
173
179
Self :: InvalidColumnIndex ( i) => write ! ( f, "Invalid column index: {i}" ) ,
174
180
Self :: InvalidColumnName ( ref name) => write ! ( f, "Invalid column name: {name}" ) ,
175
181
Self :: InvalidColumnType ( i, ref name, ref t) => {
@@ -201,6 +207,7 @@ impl error::Error for Error {
201
207
| Self :: InvalidParameterName ( _)
202
208
| Self :: ExecuteReturnedResults
203
209
| Self :: QueryReturnedNoRows
210
+ | Self :: QueryReturnedMoreThanOneRow
204
211
| Self :: InvalidColumnIndex ( _)
205
212
| Self :: InvalidColumnName ( _)
206
213
| Self :: InvalidColumnType ( ..)
0 commit comments