Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datajoint/adapters/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading