MagicStack / MagicStack/asyncpg

text encoding of composite types error with schema and table name.

未关闭
#779 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
8.1k
派生
468
PR 合并指标
30 天内没有已合并 PR

描述

  • asyncpg version: 0.23.0
  • PostgreSQL version: 10.13
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : No. I ran PG on local machine.
  • Python version: 3.8.2
  • Platform: MacOs catalina 10.15.7
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?: No
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : Not tried

Hello!

I have table with ltree column:

create table product
(
    product_id    varchar(18)                                    not null
        constraint product_pkey
            primary key,
    category_path ltree
);

And trying execute this SQL query:

    insert into product
    (product_id, category_path)
    (select  r.product_id, r.category_path from unnest($1::product[]) as r)

Args:

[[{'category_path': 'A.B', 'product_id': '3912331'}]]

And i get this error:

File "/venv/lib/python3.8/site-packages/asyncpg/pool.py", line 530, in execute
    return await con.execute(query, *args, timeout=timeout)
  File "/venv/lib/python3.8/site-packages/asyncpg/connection.py", line 299, in execute
    _, status, _ = await self._execute(
  File "/venv/lib/python3.8/site-packages/asyncpg/connection.py", line 1623, in _execute
    result, _ = await self.__execute(
  File "/venv/lib/python3.8/site-packages/asyncpg/connection.py", line 1648, in __execute
    return await self._do_execute(
  File "/venv/lib/python3.8/site-packages/asyncpg/connection.py", line 1675, in _do_execute
    stmt = await self._get_statement(
  File "/venv/lib/python3.8/site-packages/asyncpg/connection.py", line 392, in _get_statement
    settings.register_data_types(types)
  File "asyncpg/protocol/settings.pyx", line 35, in asyncpg.protocol.protocol.ConnectionSettings.register_data_types
  File "asyncpg/protocol/settings.pyx", line 36, in asyncpg.protocol.protocol.ConnectionSettings.register_data_types
  File "asyncpg/protocol/codecs/base.pyx", line 506, in asyncpg.protocol.protocol.DataCodecConfig.add_types
  File "asyncpg/protocol/codecs/base.pyx", line 371, in asyncpg.protocol.protocol.Codec.new_composite_codec
  File "asyncpg/protocol/codecs/base.pyx", line 76, in asyncpg.protocol.protocol.Codec.init
asyncpg.exceptions._base.UnsupportedClientFeatureError: cannot decode type "public"."product": text encoding of composite types is not supported

But "public"."product" -- it's schema and table name.

If i create new table with category_path = text instead ltree, all ok.

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

调研方向

首先使用 ltree 列和复合产品类型重现查询,然后检查 traceback 中出现的 asyncpg/protocol/settings.pyx 和 asyncpg/protocol/codecs/base.pyx。跟踪复合类型的注册,并验证针对这种情况的行为已得到修正,同时不会破坏现有的复合类型处理。

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

评估

技术栈
postgresql, python
领域
databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
38/100

把新 issue 发到你的邮箱

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