Skip to content

Support YDB native UUID type - #86

Merged
vgvoleg merged 1 commit into
mainfrom
uuid_support
Sep 14, 2026
Merged

vgvoleg merged 1 commit into
mainfrom
uuid_support

Conversation

@vgvoleg

@vgvoleg vgvoleg commented Jul 15, 2025

Copy link
Copy Markdown
Member

Closes: #84

@vgvoleg
vgvoleg requested a review from Copilot July 15, 2025 14:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for YDB's native UUID type by introducing a custom SQLAlchemy type, mapping it in the compiler and dialect, and exercising it via new tests.

  • Introduce YqlUUID to handle binding of uuid.UUID and string values into a native UUID column.
  • Extend the SQL generation and YDB type mapping to recognize UUID and map it to ydb.PrimitiveType.UUID.
  • Update the dialect’s type map and add tests for both native and string-based UUID columns.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
ydb_sqlalchemy/sqlalchemy/types.py Added YqlUUID subclass with bind processor and stub result processor
ydb_sqlalchemy/sqlalchemy/compiler/sa20.py Added visit_UUID and mapping logic in YqlTypeCompiler
ydb_sqlalchemy/sqlalchemy/init.py Mapped YDB’s PrimitiveType.UUID to sa.UUID and registered YqlUUID
test/test_core.py Imported uuid, defined test_uuid_types table and new tests for UUIDs
Comments suppressed due to low confidence (2)

test/test_core.py:322

  • Add a test case for passing an invalid UUID string into the uuid_native column to verify that a ValueError is raised by the bind processor.
    def test_uuid_types(self, connection):

ydb_sqlalchemy/sqlalchemy/types.py:17

  • [nitpick] Add a docstring for YqlUUID to describe its purpose and behavior for binding and result processing of native UUID values.
class YqlUUID(types.UUID):

Comment thread ydb_sqlalchemy/sqlalchemy/types.py Outdated
Comment thread ydb_sqlalchemy/sqlalchemy/types.py Outdated
Comment thread test/test_core.py Outdated
Comment thread ydb_sqlalchemy/sqlalchemy/compiler/sa20.py
Comment thread ydb_sqlalchemy/sqlalchemy/types.py Outdated
Comment thread ydb_sqlalchemy/sqlalchemy/types.py Outdated
Comment thread test/test_core.py Outdated
Comment thread test/test_core.py Outdated
@Mac3g0d

Mac3g0d commented Oct 4, 2025

Copy link
Copy Markdown

Hi @vgvoleg!
Any updates on this PR?
Do you need any specific help to deliver this feature to production?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The integration test table name should be unique per run to avoid collisions.

Review details

Suppressed comments (1)

tests/integration/test_core.py:259

  • This integration table has a fixed name, so concurrent or repeated dialect runs against the shared YDB database can collide with an existing test_uuid_types table (and its fixed primary-key values). Please give the table a per-run unique suffix, following the unique-name convention used by the integration suite.
            "test_uuid_types",
  • Files reviewed: 9/9 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is consistent across compilation, binding, reflection, compatibility behavior, tests, and documentation.

Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@vgvoleg
vgvoleg merged commit b7344ab into main Sep 14, 2026
7 checks passed
@vgvoleg
vgvoleg deleted the uuid_support branch September 14, 2026 15:20
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.

How to use native UUID insted of utf-8 uuid in ydb-sqlalchemy

4 participants