Skip to content

Pep249#159

Draft
danhogue wants to merge 15 commits into
long2ice:devfrom
turquoisehealth:pep249
Draft

Pep249#159
danhogue wants to merge 15 commits into
long2ice:devfrom
turquoisehealth:pep249

Conversation

@danhogue

@danhogue danhogue commented May 6, 2026

Copy link
Copy Markdown

No description provided.

danhogue and others added 14 commits May 5, 2026 10:10
- docs/pep249_requirements.md: full PEP 249 spec reference including
  module globals, exception hierarchy, type objects, connection/cursor
  interface, and SQLAlchemy-specific requirements beyond base PEP 249
- docs/pep249_implementation_plan.md: gap analysis against the current
  asynch codebase with prioritised implementation suggestions for each
  missing or incorrect item (apilevel/threadsafety/paramstyle, connect(),
  type singletons, arraysize, setoutputsize, lastrowid, callproc,
  nextset, description type_code, commit no-op)
- tests/pep249/: TDD suite covering every PEP 249 requirement
  (module globals, exceptions, type objects, connection lifecycle,
  cursor attributes/methods, execute/executemany, fetch semantics,
  description format and type_code mapping)
- tests/sqlalchemy/: compatibility suite verifying asynch provides the
  exact DB-API interface SQLAlchemy needs; Core and ORM tests skip
  gracefully when clickhouse-sqlalchemy is not installed
- Makefile: add test-pep249, test-sqlalchemy, test-compat targets that
  show all failures at once (suitable for TDD workflow)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The DSN parser was using enum objects directly in string sets instead of their
values, causing scheme validation failures when enums were used in f-strings.

Changes:
- asynch/proto/utils/dsn.py: Use .value for enum string sets and comparisons
- asynch/proto/connection.py: Fix alt_hosts URL construction with enum.value
- tests/test_proto/utils/test_dsn.py: Fix test DSN construction to use .value

The bug was introduced in commit 23da5d6 (Oct 2024) when enum imports were
updated but the string sets weren't updated to use .value.

Fixes test failures in DSN parsing and ensures proper URL scheme validation.
Reduce max_threads test from 1234 to 4 to work with 2-core Docker container.
ClickHouse auto-caps threads based on available cores, causing test failures
with unrealistic values. Test functionality remains unchanged.
- Add module globals: apilevel=2.0, threadsafety=1, paramstyle=pyformat
- Implement module-level connect() factory function with full parameter support
- Export all PEP 249 exceptions (Warning, Error, DatabaseError, etc.)
- Create asynch/dbapi_types.py with comprehensive type system:
  - Type objects: STRING, NUMBER, DATETIME, BINARY, ROWID
  - Type constructors: Date, Time, Timestamp, DateFromTicks, etc.
  - ClickHouse to PEP 249 type mapping with Nullable/LowCardinality support
- Add missing cursor methods and properties:
  - cursor.arraysize public property with getter/setter
  - cursor.setoutputsize() (renamed from setoutputsizes, kept alias)
  - cursor.lastrowid property (returns None for ClickHouse)
  - cursor.callproc() method (raises NotSupportedError per spec)
  - cursor.nextset() async method (returns None for single result sets)
- Fix cursor.description to use PEP 249 type objects and return None for non-SELECT
- Change connection.commit() from raising NotSupportedError to no-op behavior
- Fix cursor and connection __repr__ methods to show clean status strings
@danhogue danhogue marked this pull request as draft May 6, 2026 19:23
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.

1 participant