You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to add informative errors? Handling of errors such as violation of unique constraint or missing rows in the query result leaves much to be desired.
The text was updated successfully, but these errors were encountered:
I can't add it to the test code, though, because the error message changes slightly with different versions of firebird,
The following test passes on my machine.
+func TestGoIssue183(t *testing.T) {
+ testDsn := GetTestDSN("test_issue183")
+ conn, err := sql.Open("firebirdsql_createdb", testDsn)
+ defer conn.Close()
+
+ query := "CREATE TABLE t (text VARCHAR(1) UNIQUE)"
+ _, err = conn.Exec(query)
+
+ require.NoError(t, err)
+
+ _, err = conn.Exec("INSERT INTO t VALUES ('A')")
+ require.NoError(t, err)
+
+ _, err = conn.Exec("INSERT INTO t VALUES ('A')")
+ assert.EqualError(t, err, "violation of PRIMARY or UNIQUE KEY constraint \"INTEG_1\" on table \"T\"\nProblematic key value is (\"TEXT\" = 'A')\n")
+}
+
This message is returned by the Firebird server.
Do you expect any better error handling than this?
Can you describe specifically how you expect it to be done?
Is it possible to add informative errors? Handling of errors such as violation of unique constraint or missing rows in the query result leaves much to be desired.
The text was updated successfully, but these errors were encountered: