UnmappedColumnError when using mapped_args and version_id_col for optimistic concurrency control #1191
Replies: 2 comments
-
For those having similar problems, I found the solution, which is using the class Record(SQLModel, table=True):
"""Status list for credentials."""
__tablename__ = "records"
id: int | None = Field(default=None, primary_key=True, unique=True)
name: str
version: int = Field(sa_column=sa.Column(sa.Integer, nullable=False, default=1))
__mapper_args__ = {
"version_id_col": version.sa_column,
"version_id_generator": False} |
Beta Was this translation helpful? Give feedback.
0 replies
-
I must reopen this question, because the above code does not fail, but it does not update the version column in the posgresql table. Do anyone has successfully implemented optimistic concurrency with postgreslq? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
version_id_col
sosqlalchemy
can handle optimistic concurrency for meBut I'm getting the following exception:
sqlalchemy.orm.exc.UnmappedColumnError: No column version is configured on mapper Mapper[Record(records)]...
Operating System
Linux
Operating System Details
Ubuntu 20.04
SQLModel Version
0.0.22
Python Version
3.10.12
Additional Context
SQLAlchemy documentation of version_id_col in mapper_args.
Beta Was this translation helpful? Give feedback.
All reactions