| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Rather than integer based serialization grandfathered in from sqlalchemy, use the stdlib [`UUID.hex`](https://docs.python.org/3/library/uuid.html#uuid.UUID.hex) method. This also fixes fastapi#25
|
any update? |
Sorry, something went wrong.
|
I will just propose also adding a small test, just to catch this. I made my own small test to catch the behaviour in a fork to fix this, before finding this pr, so you can maybe work something off of this (probably want to generalize a bit - I made it really quick just to confirm this was causing the issue): def test_zero_padded_uuid():
raised = None
myid = UUID(hex='00000000000000000000000000000001')
stored_value = GUID().process_bind_param(myid, SQLiteDialect)
try:
back_to_uuid = GUID().process_result_value(stored_value, SQLiteDialect)
except ValueError as ex:
raised = ex
assert raised is None
assert myid == back_to_uuid |
Sorry, something went wrong.
|
@tiangolo - Do you have any other maintainers that can help get small PRs like this merged? I'm also up against this issue, and the PR was opened 2 months ago. |
Sorry, something went wrong.
|
Any news on this? |
Sorry, something went wrong.
|
I am disappointed that this simple fix was not implemented in 0.0.5, as this is causes a lot of headaches when using UUID primary keys. |
Sorry, something went wrong.
|
I was just about to create an issue about it and implement the exactly same solution. Looks like SQLModel got inspired by the same source of this gist: https://gist.github.com/gmolveau/7caeeefe637679005a7bb9ae1b5e421e IMHO I think SQLAlquemy-Utils uses a better approach when it provides additional native dialects besides postgresql, like msql and cockroachdb, and also uses the native UUID .hex property in serialization. https://sqlalchemy-utils.readthedocs.io/en/latest/_modules/sqlalchemy_utils/types/uuid.html#UUIDType |
Sorry, something went wrong.
Fork 3 (Sourcery refactored)
Codecov Report
@@ Coverage Diff @@
## main #26 +/- ##
=======================================
Coverage 97.59% 97.59%
=======================================
Files 182 182
Lines 6060 6060
=======================================
Hits 5914 5914
Misses 146 146
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Sorry, something went wrong.
|
📝 Docs preview for commit 9bb4715 at: https://630a99822de66e5008e74d00--sqlmodel.netlify.app |
Sorry, something went wrong.
|
Great! This makes sense, thank you @andrewbolster! 🍰 And thanks everyone for the discussion! ☕ This will be available in the next version, released in the next hours, SQLModel 0.0.7. 🎉 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Rather than integer based serialization grandfathered in from sqlalchemy, use the stdlib UUID.hex method.
This also fixes #25