ydb-platform / ydb-platform/ydb-sqlalchemy

UInt64 values incorrectly inferred as Int64 in SQLAlchemy parameter binding

Open
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40
Forks
13
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Root Cause

The YDB SQLAlchemy driver incorrectly infers parameter types, treating UInt64 values as Int64
Problem occurs in the type handling logic of BaseYqlCompiler when processing expanding parameters (IN clauses)
Naked queries work fine in YDB, confirming this is a driver-level issue

Workarounds
query = select(table.c.id).where(
    table.c.id.in_(bindparam("ids", type_=ydb_sa_types.ListType(ydb_sa_types.Uint64)))
)
session.execute(query, {"ids": [16140901099660902405]})

looks the problem from here https://github.com/ydb-platform/ydb-sqlalchemy/blob/0.1.8/ydb_sqlalchemy/sqlalchemy/compiler/base.py#L317

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.

Research direction

Start in ydb_sqlalchemy/sqlalchemy/compiler/base.py around line 317 and inspect type handling for expanding parameters in IN clauses. Run the provided UInt64 query example, then verify that parameter binding preserves UInt64 rather than inferring Int64 for large values.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.