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

Editing a model fails with an incorrect id value in the query #413

Closed
2 tasks done
L1st3r opened this issue Jan 18, 2023 · 4 comments · Fixed by #416
Closed
2 tasks done

Editing a model fails with an incorrect id value in the query #413

L1st3r opened this issue Jan 18, 2023 · 4 comments · Fixed by #416

Comments

@L1st3r
Copy link

L1st3r commented Jan 18, 2023

Checklist

  • The bug is reproducible against the latest release or master.
  • There are no similar issues or pull requests to fix it yet.

Describe the bug

Tried editing a model and it crashed. I had to wrap the "rows = await self._run_query(stmt)" line in the get_model_objects function in the models.py file to get an exception (no exceptions get pushed to output or logged!)
Exception:

ProgrammingError("(sqlalchemy.dialects.postgresql.asyncpg.ProgrammingError) <class 'asyncpg.exceptions.UndefinedFunctionError'>: operator does not exist: bigint = character varying HINT: No operator matches the given name and argument types. You might need to add explicit type casts.")

The query generated had this for the where clause:

WHERE company.id = :id_8

Obviously the company.id is a bigint, and it shows the correct id of '1' in the admin list view...

Steps to reproduce the bug

No response

Expected behavior

No response

Actual behavior

No response

Debugging material

No response

Environment

WSL 2
Python 3.11.1
Latest SQLAdmin

Additional context

No response

@aminalaee
Copy link
Owner

Hey,
can you provide your minimal model to produce the error?
Did you have BigInt for the id field?

@L1st3r
Copy link
Author

L1st3r commented Jan 19, 2023

Yes they are bigints. I can try to sanitize my models

@L1st3r
Copy link
Author

L1st3r commented Jan 19, 2023

class Company(Base):
    id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True, index=True)
    name = Column(String, index=True)
    address1 = Column(String)
    address2 = Column(String)
    city = Column(String)
    state = Column(String)
    zip = Column(String)

    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

Thankfully I was able to remove all the relationships and it still fails!

@aminalaee
Copy link
Owner

Yeah it's a weird case happening with asyncpg only.

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 a pull request may close this issue.

2 participants