Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

MySQL error 1143 (column-level SELECT denied) is not translated to AccessError

未关闭 适合新手
#1,586 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
mysql, python
领域
databases

调研方向

从 src/datajoint/adapters/mysql.py 中的 translate_error 开始,其中 case 1044 | 1142: 分支将访问错误映射为 AccessError。阅读现有的访问错误测试,了解受限 MySQL 用户是如何设置的,然后添加一个具有列级 GRANT SELECT (...) 权限的用户。完成标准是:错误 1143 会抛出 dj.errors.AccessError,并且有一个测试覆盖列级权限被拒绝的查询。

由索引模型根据 Issue 内容生成。

描述

bug

On MySQL, a query that names a column the user has no privilege on fails with error 1143. DataJoint
passes that error through as a raw pymysql.err.OperationalError. The table-level equivalent, 1142, is
translated to dj.errors.AccessError. Code that catches AccessError to handle a missing privilege
therefore misses column-level grants.

Reproduction
import datajoint as dj

admin = dj.Connection("127.0.0.1", "root", "simple", 3306)
schema = dj.Schema("demo_access", connection=admin)


@schema
class Measurement(dj.Manual):
    definition = """
    measurement_id: int32
    ---
    value: float64
    operator: varchar(32)
    """


@schema
class Note(dj.Manual):
    definition = """
    note_id: int32
    ---
    text: varchar(64)
    """


# '%%' because Connection.query formats its arguments
admin.query("CREATE USER 'reader'@'%%' IDENTIFIED BY 'pw'")
admin.query("GRANT SELECT (measurement_id, value) ON demo_access.measurement TO 'reader'@'%%'")
reader = dj.Connection("127.0.0.1", "reader", "pw", 3306)

reader.query("SELECT text FROM demo_access.note")
# datajoint.errors.AccessError: ('Insufficient privileges.', "SELECT command denied ... for table 'note'", ...)

reader.query("SELECT operator FROM demo_access.measurement")
# pymysql.err.OperationalError: (1143, "SELECT command denied ... for column 'operator' in table 'measurement'")

Observed on MySQL 8.0 with master at b9ace66.

Expected behavior

1143 raises dj.errors.AccessError, like 1044 and 1142. The PostgreSQL adapter already maps
insufficient_privilege (42501) to AccessError for table and column denials alike, so the change also
makes the two backends agree.

Where

src/datajoint/adapters/mysql.py, translate_error: case 1044 | 1142: becomes case 1044 | 1142 | 1143:.
A test beside the existing access-error tests would need a user with a column-level grant.

主要语言
Python
星标
197
派生
99
平均合并
1 天 11 小时
30 天内合并 PR
10

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

datajoint/datajoint-python 的其他 Issue

查看 datajoint/datajoint-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。