Skip to content

Commit c6af82e

Browse files
Bhanu73120dimitri-yatsenko
authored andcommitted
fix(mysql): translate column access error 1143
(cherry picked from commit 82f90c4)
1 parent 68fdea5 commit c6af82e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎src/datajoint/adapters/mysql.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ def translate_error(self, error: Exception, query: str = "") -> Exception:
10291029
return errors.LostConnectionError("Server connection lost", *args)
10301030

10311031
# Access errors
1032-
case 1044 | 1142:
1032+
case 1044 | 1142 | 1143:
10331033
query = args[0] if args else ""
10341034
return errors.AccessError("Insufficient privileges.", args[0] if args else "", query)
10351035

‎tests/unit/test_adapters.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,19 @@ def test_job_metadata_columns_postgres(self, postgres_adapter):
572572
assert "varchar(64)" in sql[2]
573573
# PostgreSQL carries no inline comment; it is applied via COMMENT ON.
574574
assert "COMMENT" not in sql[0].upper()
575+
576+
577+
class TestMySQLErrorTranslation:
578+
"""Tests for MySQL error translation."""
579+
580+
def test_column_permission_denied(self):
581+
"""MySQL error 1143 should become AccessError."""
582+
from datajoint import errors
583+
584+
adapter = MySQLAdapter()
585+
586+
mysql_error = Exception(1143, "SELECT command denied for column 'salary'")
587+
588+
result = adapter.translate_error(mysql_error)
589+
590+
assert isinstance(result, errors.AccessError)

0 commit comments

Comments
 (0)