I want to directly know which column cause UniqueViolationError, but not from e.message or e.detail.
I need it because I want to build my own message to my API consumer.
Currently I just expose the UniqueViolationError.detail, which I think unsafe.
try:
ins_res = await app.db.fetchrow(user_tbl.insert().values(**user.to_native('create')))
except UniqueViolationError as e:
return json({'message': e.detail}, status=409)
- asyncpg version: 0.12.0
- PostgreSQL version: PostgreSQL 10.0 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18) 6.3.0 20170516, 64-bit
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: No; Yes
- Python version: 3.6.2
- Platform: Ubuntu 16.04.3/Linux 4.4.0-97-generic
- Do you use pgbouncer?: I dont know
- Did you install asyncpg with pip?: not exactly, I use pipenv
- If you built asyncpg locally, which version of Cython did you use?: No
- Can the issue be reproduced under both asyncio and
uvloop?: Not tested
I want to directly know which column cause
UniqueViolationError, but not frome.messageore.detail.I need it because I want to build my own message to my API consumer.
Currently I just expose the
UniqueViolationError.detail, which I think unsafe.the issue with a local PostgreSQL install?: No; Yes
uvloop?: Not tested