Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uuids always producing the same result: #482

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Conversation

MelissaAutumn
Copy link
Member

  • Pass uuid as a callable not a result
  • Fix re-create the uuid index to make them unique
  • Re-generate all uuids
  • Add tests to test uniqueness.

Easy mistake to miss, now fixed and tested.

* Pass uuid as a callable not a result
* Fix re-create the uuid index to make them unique
* Re-generate all uuids
* Add tests to test uniqueness.
Copy link
Collaborator

@devmount devmount left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, also thanks for the tests. Just one question/suggestions.

@@ -179,7 +179,7 @@ class Appointment(Base):
__tablename__ = 'appointments'

id = Column(Integer, primary_key=True, index=True)
uuid = Column(UUIDType(native=False), default=uuid.uuid4(), index=True)
uuid = Column(UUIDType(native=False), default=uuid.uuid4, index=True, unique=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLAlchemy also provides a Uuid type since 2.0, I think using that could prevent issues with default values maybe.
https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.Uuid

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also thanks for adding unique=True! How could we possibly miss that 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally don't need uniqueness because most if not everything is scoped by the subscriber. But I felt like it'd be silly not to unique a uuid.

And I can make a ticket for that in the future!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. Thank you!

@MelissaAutumn MelissaAutumn merged commit de5623a into main Jun 13, 2024
4 checks passed
@MelissaAutumn MelissaAutumn deleted the tasks/fix-uuid branch June 13, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants