MagicStack / MagicStack/asyncpg
Nested custom types in Postgres break `asyncpg.Record` subclassing
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
-
asyncpg version: v0.25.0
-
PostgreSQL version: 14
-
Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: on-premise -
Python version: 3.10.1
-
Platform: linux
-
Do you use pgbouncer?: no
-
Did you install asyncpg with pip?: yes
-
If you built asyncpg locally, which version of Cython did you use?: n/a
-
Can the issue be reproduced under both asyncio and
uvloop?: n/a
It would appear that nested types are not converted to a user specified record_class, and instead will always use asyncpg.Record.
For example:
CREATE TYPE my_custom_type AS (
id int,
filename text,
sql text
);
CREATE TABLE my_table (
files my_custom_type[] NOT NULL,
);
SELECT * FROM my_table
If you specify a custom record_class, then the record from SELECT * FROM my_table will be your subclass. However, the value inside record['files'] will use the asyncpg.Record class, rather than the custom one specified.
What should actually happen?
I think if a user specifies a record_class, then this class should always be used, even for nested custom types. It's quite unexpected behaviour for asyncpg to use the default class when a custom one has been specified.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用报告中描述的自定义 PostgreSQL 类型、数组列、SELECT 查询和自定义 record_class 重现该问题。跟踪嵌套自定义类型值的解码方式以及 record_class 的传递方式;当 record['files'] 中的记录使用指定的子类而不是 asyncpg.Record,并且此案例有回归测试覆盖时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100