Skip to content

Conversation

@Mac3g0d
Copy link

@Mac3g0d Mac3g0d commented Jun 19, 2025

copy
#20
from @abdalazizrashid

with passed codestyle but not fully tested
for base case like simple table with strings, ints, and uuidv7 as primary_key its works fine

Виктор Жирнов added 2 commits June 19, 2025 18:46
@vgvoleg
Copy link
Collaborator

vgvoleg commented Jul 9, 2025

Hi! have you followed instructions described here? alembic works fine with them
https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic

@Mac3g0d
Copy link
Author

Mac3g0d commented Jul 13, 2025

Hi! have you followed instructions described here? alembic works fine with them https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic

Hi @vgvoleg!
Sorry, I made a mistake.
The problem is as follows: if you specify a naming convention in the metadata that you set in the Base class and then pass it to other classes, SQLAlchemy thinks that the field is a primary key and tries to generate a string like
PRIMARY KEY ...

Here is an example of the base class code that breaks the YQL dialect:

convention = {
    "ix": "ix_%(column_0_label)s",
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(constraint_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s",
}

class Base(DeclarativeBase):
    __abstract__ = True

    metadata = MetaData(naming_convention=convention)

I solved my problem, I will cancel the PR, but probably this case should be recorded as a bug.

@Mac3g0d Mac3g0d closed this Jul 13, 2025
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