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

Documentation: Add section about using gen_random_text_uuid as auto-PK #585

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

amotl
Copy link
Member

@amotl amotl commented Sep 28, 2023

About

CrateDB 4.5.0 added the gen_random_text_uuid() scalar function, which can also be used within an SQL DDL statement, in order to automatically assign random identifiers to newly inserted records on the server side. In this spirit, it is suitable to be used as a PRIMARY KEY constraint for SQLAlchemy.

This patch adds a corresponding documentation section how to use it with SQLAlchemy.

References

/cc @surister

Copy link
Member

@seut seut left a comment

Choose a reason for hiding this comment

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

lgtm otherwise

.. code-block:: sql

CREATE TABLE "doc"."items" (
"id" STRING DEFAULT gen_random_text_uuid() NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"id" STRING DEFAULT gen_random_text_uuid() NOT NULL,
"id" STRING DEFAULT gen_random_text_uuid() NOT NULL PRIMARY KEY,

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks.

@amotl amotl force-pushed the amo/sa-autopk-gen_random_text_uuid branch from fa2c4e1 to 7bcfab4 Compare September 29, 2023 07:47
@amotl amotl merged commit 471f026 into master Sep 29, 2023
23 of 25 checks passed
@amotl amotl deleted the amo/sa-autopk-gen_random_text_uuid branch September 29, 2023 07:48
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.

SQLAlchemy/DDL: Support custom crate_autogenerate_uuid column definition option
2 participants