Double casting UUID field with parameter as_uuid=True
See original GitHub issueHello, I’ve got an error when trying to use something like that:
id = Column(
UUID(as_uuid=True), # I need to use id as UUID object
default=uuid.uuid4,
primary_key=True,
)
UUID: from sqlalchemy.dialects.postgresql import UUID
I’ve also tested this logic at dockerized PostgreSQL v10.14 with psycopg2 - all works as expected.
So somewhere it tries to make code like uuid.UUID(<uuid.UUID object>)
File "<input>", line 1, in <module>
File "/usr/local/lib/python3.9/uuid.py", line 174, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'UUID' object has no attribute 'replace'```
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How can I use UUIDs in SQLAlchemy?
I've been refining a UUID column type for the past few months and I think I've finally got it solid. from sqlalchemy import...
Read more >Casting an array of texts to an array of UUIDs
The users table is currently empty (0 records). I have tried. ALTER TABLE "users" ALTER COLUMN "project_ids" SET DATA TYPE UUID ...
Read more >UuidBinary (or array of uuid) as parameter for QueryBuilder
When doctrine make query with array of uuids as parameter, every uuid cast to string. Result match nothing, because need cast to Bytes....
Read more >Jmeter | Generate UUID (Unique Identifier) | by Priyank Shah
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer ... Pass user parameter UUID to the HTTP...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for bringing this up. I wasn’t able to figure out how to configure the SQLAlchemy driver API to handle UUID objects correctly when the underlying DB-API driver has already converted them to native types, so I reverted the PR in question and made a new release that should fix the problem, and added a regression test. Pleas let me know if this does not fix the problem for you.
Hi @Kostiantyn-Salnykov I am having the same problem. I downgraded aurora-data-api to a version released before the PR you linked, v0.2.5, and things started working again.