Problems with Strings as primary_key/foreign_key on SQL Dialects that require Length #844
Unanswered
Freshpinguin
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Iam trying to have a string as a primary key and foreign Key in SQLModel using MariaDB.
As the MariaDB dialect requires me to define the length of a string, i need to define fields using the sa_column key word argument in Field using the Column Object from SQLAlchemy.
This works for primary_key as the SQLAlchemy Object Column supports the key word argument primary_key.
But it doesn't support foreign_key so that does not work.
Also passing sa_column and foreign_key or primary_key to Field raises:
RuntimeError(
"Passing primary_key is not supported when "
"also passing a sa_column"
)
from SQLModels FieldInfo Object.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.16
Python Version
Python 3.12.0
Additional Context
This is my first time ever asking a question on Github, so feedback is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions