Skip to content

Conversation

@cofin
Copy link
Member

@cofin cofin commented Dec 4, 2025

Summary

Adds fetch* method aliases to sync and async driver base classes, providing an alternative naming convention for users familiar with asyncpg's API. Both select* (primary) and fetch* (alias) naming conventions are fully supported.

The Problem

Users coming from asyncpg expect methods like fetch(), fetchrow(), and fetchval(). SQLSpec uses select(), select_one(), and select_value() which, while more semantic, can feel unfamiliar to asyncpg users.

The Solution

Add wrapper methods that delegate to the existing select* methods with full type safety through duplicated @overload decorators. Both conventions work identically with zero performance overhead.

Key Features

  • 7 new sync methods: fetch(), fetch_one(), fetch_one_or_none(), fetch_value(), fetch_value_or_none(), fetch_to_arrow(), fetch_with_total()
  • 7 new async methods: Same methods with async implementations
  • Full type safety with duplicated overloads for proper IDE support
  • 44 unit tests verifying equivalence and delegation behavior
  • Documentation updated in drivers_and_querying.rst

@cofin cofin changed the title feat(driver): add fetch* method aliases for asyncpg compatibility feat(driver): add fetch* method aliases compatibility Dec 4, 2025
cofin added 2 commits December 3, 2025 21:28
Add fetch* method aliases to both sync and async driver base classes,
providing an alternative naming convention for users familiar with
asyncpg's API. Both select* (primary) and fetch* (alias) conventions
are fully supported with complete type safety.
@cofin cofin merged commit e26375f into main Dec 4, 2025
10 checks passed
@cofin cofin deleted the feat/fetch-alias branch December 4, 2025 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants