From 82f90c449ab969abc970283c689b06571fbe4568 Mon Sep 17 00:00:00 2001 From: Bhanu Prakash Date: Wed, 14 Oct 2026 06:40:47 +0000 Subject: [PATCH] fix(mysql): translate column access error 1143 --- src/datajoint/adapters/mysql.py | 2 +- tests/unit/test_adapters.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/datajoint/adapters/mysql.py b/src/datajoint/adapters/mysql.py index 2ef9baf84..7a31e31e7 100644 --- a/src/datajoint/adapters/mysql.py +++ b/src/datajoint/adapters/mysql.py @@ -1029,7 +1029,7 @@ def translate_error(self, error: Exception, query: str = "") -> Exception: return errors.LostConnectionError("Server connection lost", *args) # Access errors - case 1044 | 1142: + case 1044 | 1142 | 1143: query = args[0] if args else "" return errors.AccessError("Insufficient privileges.", args[0] if args else "", query) diff --git a/tests/unit/test_adapters.py b/tests/unit/test_adapters.py index bd0afa9e0..9c0a68f53 100644 --- a/tests/unit/test_adapters.py +++ b/tests/unit/test_adapters.py @@ -572,3 +572,19 @@ def test_job_metadata_columns_postgres(self, postgres_adapter): assert "varchar(64)" in sql[2] # PostgreSQL carries no inline comment; it is applied via COMMENT ON. assert "COMMENT" not in sql[0].upper() + + +class TestMySQLErrorTranslation: + """Tests for MySQL error translation.""" + + def test_column_permission_denied(self): + """MySQL error 1143 should become AccessError.""" + from datajoint import errors + + adapter = MySQLAdapter() + + mysql_error = Exception(1143, "SELECT command denied for column 'salary'") + + result = adapter.translate_error(mysql_error) + + assert isinstance(result, errors.AccessError)