Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support errors #183

Open
sacredcrane opened this issue Jan 17, 2025 · 1 comment
Open

Support errors #183

sacredcrane opened this issue Jan 17, 2025 · 1 comment

Comments

@sacredcrane
Copy link

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.

@nakagami
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants