Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pk uuid dont work correctly #193

Open
BAIBASH1 opened this issue Dec 23, 2024 · 0 comments
Open

pk uuid dont work correctly #193

BAIBASH1 opened this issue Dec 23, 2024 · 0 comments

Comments

@BAIBASH1
Copy link

BAIBASH1 commented Dec 23, 2024

i find a loggical issue at crud/_sqlalchemy.py/114 :

pk_name: str = "id"  # Primary key name
parser: TableModelParser = None  # Table model parser

def __init__(self, model: Type[TableModelT] = None, fields: List[SqlaField] = None) -> None:
    self.model = model or self.model
    assert self.model, "model is None"
    assert hasattr(self.model, "__table__"), "model must be has __table__ attribute."
    self.pk_name: str = self.pk_name or self.model.__table__.primary_key.columns.keys()[0]

the right thing to do is to change
self.pk_name: str = self.pk_name or self.model.__table__.primary_key.columns.keys()[0] to
self.pk_name: str = self.model.__table__.primary_key.columns.keys()[0] or self.pk_name :

pk_name: str = "id"  # Primary key name
parser: TableModelParser = None  # Table model parser

def __init__(self, model: Type[TableModelT] = None, fields: List[SqlaField] = None) -> None:
    self.model = model or self.model
    assert self.model, "model is None"
    assert hasattr(self.model, "__table__"), "model must be has __table__ attribute."
    self.pk_name: str = self.model.__table__.primary_key.columns.keys()[0] or self.pk_name
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

No branches or pull requests

1 participant