Skip to content

Conversation

pauloxnet
Copy link
Member

@pauloxnet pauloxnet commented Mar 29, 2017

Added CryptoExtension (pgcrypto) extension and RandomUUID
(GEN_RANDOM_UUID) function to contrib.postgres

Ticket #27996

Copy link
Member

Choose a reason for hiding this comment

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

I think this deserves 2 bullet points. One for RandomUUID and one for pgcrypto.

Copy link
Member

Choose a reason for hiding this comment

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

Can you please leave this line at the end or make sure that the comment above still goes with the CreateExtension('uuid-ossp') line.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right I alphabetical ordered the operation but I forgot to move the comment too. I'm fixing it.

Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this sleep function? If RandomUUID returns the same UUID for two consecutive calls at the same second that seems to be a bug in PostgreSQL.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually it's only a dead code I forgot to delete, I'm going to remove it.

Copy link
Member

Choose a reason for hiding this comment

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

I think you can omit (random) here.

Copy link
Member

Choose a reason for hiding this comment

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

This needs to state that it needs the extension installing.

Also wouldn't hurt to include the canonical example code.

Even better, let's test whether UUIDField(default=RandomUUID) works - if it does let's document that both here and in the UUID docs as a note for PG users. (sounds like it doesn't but let's verify)

Copy link
Member

Choose a reason for hiding this comment

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

This test would be better if we updated the whole model with the expression, like in the PR

Copy link
Contributor

Choose a reason for hiding this comment

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

allow allows

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I'm going to fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could use _output_field = UUIDField() at the class level instead of this?

Copy link
Member

Choose a reason for hiding this comment

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

That's slightly too much magic than I'd like, I think. Thoughts on that @jarshwah?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used the same convention that I found in the same file for TransactionNow function.

Copy link
Member

Choose a reason for hiding this comment

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

Then it's settled, I think. Thanks :)

Copy link
Member

Choose a reason for hiding this comment

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

That's slightly too much magic than I'd like, I think. Thoughts on that @jarshwah?

Copy link
Member

Choose a reason for hiding this comment

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

I believe referencing INSTALLED_APPS here is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to align this note to the same note I found into lookups.txt

Copy link
Member

Choose a reason for hiding this comment

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

Hmm ... Could you stick to the style of the current file?

Copy link
Member

Choose a reason for hiding this comment

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

"To use RandomUUID you have to have the pgcrypto extension installed."

Copy link
Member

Choose a reason for hiding this comment

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

But I'm happy to defer to @timgraham for suggestions.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to modify it as you suggested.

@pauloxnet
Copy link
Member Author

I'm waiting for the tests to be run on all databases.

@pauloxnet
Copy link
Member Author

All checks have passed, I hope this will merged.

@timgraham timgraham force-pushed the pgcrypto branch 3 times, most recently from ddaf9bc to 8cd8f59 Compare April 25, 2017 23:36
@timgraham timgraham merged commit fcb5dbf into django:master Apr 26, 2017
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.

6 participants