From cddac82d55f874380f7bc53bb7031f30255fbe23 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 31 Oct 2023 11:59:53 -0700 Subject: [PATCH] Do not use SQL states for exceptions in jdbc/sqlanywhere adapter The sqlanywhere JDBC driver (or SQLAnywhere itself) has broken SQL State handling, using 23000 for most constraint exceptions. Changes made in 813db795a77687b9a639fe889b038e7a0e46829e to make the jdbc adapter consider SQL states of the current exception resulted in the use of SQL states in the jdbc/sqlanywhere, where they didn't work correctly. Explicitly mark the jdbc/sqlanywhere adapter to not handle SQL states. The shared sqlanywhere adapter handles the exception mapping correctly in this case. --- lib/sequel/adapters/jdbc/sqlanywhere.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sequel/adapters/jdbc/sqlanywhere.rb b/lib/sequel/adapters/jdbc/sqlanywhere.rb index b3431bde3f..34f5f0867e 100644 --- a/lib/sequel/adapters/jdbc/sqlanywhere.rb +++ b/lib/sequel/adapters/jdbc/sqlanywhere.rb @@ -36,6 +36,10 @@ module DatabaseMethods private + def database_exception_use_sqlstates? + false + end + # Use @@IDENTITY to get the last inserted id def last_insert_id(conn, opts=OPTS) statement(conn) do |stmt|