MagicStack / MagicStack/asyncpg
Cannot create type codec for composite type with certain field types.
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hello, I noticed I can't create a type codec for a composite type if it has a field of type json, a jsonb or a geometry type. Why is so and is there a way to sidestep this issue?
import json
from dataclasses import dataclass
@dataclass
class Foo:
data: dict
await conn.execute("CREATE TABLE foo (data jsonb NOT NULL);")
await conn.set_type_codec(
"foo",
schema="public",
encoder=lambda foo: (json.dumps(foo.data),),
decoder=lambda row: Foo(json.loads(row)),
format="tuple",
)
UnsupportedClientFeatureError: cannot decode type "public"."foo": text encoding of composite types is not supported
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先通过 conn.set_type_codec 使用包含 jsonb 字段的复合类型重现该示例,然后检查复合 codec 的处理方式以及 PostgreSQL 类型格式的约束。完成的标准是确定支持所报告的字段类型,或清楚地记录该限制和一种受支持的变通方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- databases
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100