2
0

Select(Value|Row) require exactly one found row

This commit is contained in:
Jack Christensen
2013-06-29 13:23:26 -05:00
parent aabf563a3b
commit 08801c2fe4
2 changed files with 24 additions and 12 deletions
+13 -3
View File
@@ -194,8 +194,13 @@ func TestSelectRow(t *testing.T) {
}
_, err = conn.SelectRow("select 'Jack' as name where 1=2")
if _, ok := err.(NoRowsFoundError); !ok {
t.Error("No matching row should have returned NoRowsFoundError")
if _, ok := err.(NotSingleRowError); !ok {
t.Error("No matching row should have returned NotSingleRowError")
}
_, err = conn.SelectRow("select * from (values ('Matthew'), ('Mark')) t")
if _, ok := err.(NotSingleRowError); !ok {
t.Error("Multiple matching rows should have returned NotSingleRowError")
}
}
@@ -223,9 +228,14 @@ func TestConnectionSelectValue(t *testing.T) {
test("select 1.23::float8", float64(1.23))
_, err := conn.SelectValue("select 'Jack' as name where 1=2")
if _, ok := err.(NoRowsFoundError); !ok {
if _, ok := err.(NotSingleRowError); !ok {
t.Error("No matching row should have returned NoRowsFoundError")
}
_, err = conn.SelectValue("select * from (values ('Matthew'), ('Mark')) t")
if _, ok := err.(NotSingleRowError); !ok {
t.Error("Multiple matching rows should have returned NotSingleRowError")
}
}
func TestSelectValues(t *testing.T) {