Skip to content

Conversation

@surister
Copy link
Member

@surister surister commented Nov 7, 2025

Summary of the changes / Why this is an improvement

This just adds new tests on id generation.

Checklist

Copy link
Member

@amotl amotl left a comment

Choose a reason for hiding this comment

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

👍

)
assert (
sql
== "INTEGER GENERATED ALWAYS AS CAST((random() * 1.0E9) AS integer) NOT NULL PRIMARY KEY"
Copy link
Member

Choose a reason for hiding this comment

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

Just curious: Is the library using random numbers to auto-generate primary key values?

Copy link
Member Author

Choose a reason for hiding this comment

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

Django expects auto generated fields to be integers, we do not have auto-incremental integers.
So we cannot use gen_random_text_uuid. If they are not integers things fall apart in many places, we could also use current timestamp but I don't want to deal right now with timestamp generation collision or any of the kind, so I chose to just generate a random number as a pk.

Copy link
Member Author

Choose a reason for hiding this comment

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

The ideal solution is that they improve auto fields to let us choose which datatype it is (it's on the works), then we can just use TEXT and gen_random_text_uuid

@surister surister merged commit dba827f into master Nov 10, 2025
2 checks passed
@surister surister deleted the fix/id_tests branch November 10, 2025 09:39
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.

Custom id is not respected - id repeated twice

3 participants