question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Double casting UUID field with parameter as_uuid=True

See original GitHub issue

Hello, 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kislyukcommented, Feb 28, 2022

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.

1reaction
carolina-cascadecommented, Feb 8, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found