Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Not accepting str as value for interval/date columns

Open
#1,169 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
postgresql, python, sqlalchemy
Domain
databases

Research direction

Start by reproducing the SQLAlchemy example with the stated PostgreSQL 15.7 and Python 3.11 setup, then trace asyncpg parameter handling for interval and date values. Compare string inputs with PostgreSQL's accepted interval syntax and add regression coverage that captures the intended result.

Written by the indexing model from the issue text.

Description

  • asyncpg version: 0.29.0
  • PostgreSQL version: 15.7
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : local
  • Python version: 3.11
  • Platform: Windows
  • 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?
    : yes

I am using asyncpg as the driver for SQLAlchemy.

class Table(Base):
    __tablename__ = 'table'
    interval: Mapped[timedelta]

session.add(Table(interval='1 min'))

With the above code, it throws this error:
sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.DataError'>: invalid input for query argument $9: '1 min' ('str' object has no attribute 'days')

However, Postgresql accepts '1 min' as a value to an interval column. Why is asyncpg forbidding str even though Postgresql accepts it in this case?

Dominant language
Python
Stars
8.1k
Forks
469
Avg merge
2d 20h
Merged PRs (30d)
9

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MagicStack/asyncpg

All issues in MagicStack/asyncpg

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.