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

Add format argument to UUIDField #2788

Closed
wants to merge 1 commit into from
Closed

Conversation

ovangle
Copy link
Contributor

@ovangle ovangle commented Apr 2, 2015

To allow serializations to control the representation format of a
UUID value

@jpadilla
Copy link
Member

jpadilla commented Apr 4, 2015

LGTM

@xordoquy xordoquy added this to the 3.1.2 Release milestone Apr 8, 2015
@xordoquy
Copy link
Collaborator

xordoquy commented Apr 8, 2015

Seconded here.

- `'hex'` - The compact hex representation of the UUID, not including hyphens
- `'int'` - A 128 bit integer representation of the UUID.
- `'urn'` - RFC 4122 URN representation of the UUID
The `to_internal_value` will accept any of the string formats of a UUID unless the `format` is `'int'`, when it will accept a
Copy link
Collaborator

@xordoquy xordoquy Apr 8, 2015

Choose a reason for hiding this comment

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

This looks truncated.

To allow serializations to control the representation format of a
UUID value
@gio82
Copy link

gio82 commented Apr 17, 2015

+1

if self.uuid_format == 'hex_verbose':
return str(value)
else:
return getattr(value, self.uuid_format)
Copy link
Member

@tomchristie tomchristie Apr 17, 2015

Choose a reason for hiding this comment

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

Are we always going to be handling the int case correctly here? Any cases where that can just be an int, rather than a UUID instance?

Copy link
Contributor Author

@ovangle ovangle Apr 17, 2015

Choose a reason for hiding this comment

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

I'm not entirely sure what potential problem you foresee here.

Which int case? The case where format is 'int', or the case where an int has somehow been passed to to_representation? None of the other fields check too rigorously for an incorrect type being passed to to_representation.

@tomchristie
Copy link
Member

tomchristie commented Apr 17, 2015

One query worth having a quikc think about but otherwise reckon I'm happy for this to go in.

- `'hex_verbose'` - The cannoncical hex representation, including hyphens
- `'hex'` - The compact hex representation of the UUID, not including hyphens
- `'int'` - A 128 bit integer representation of the UUID.
- `'urn'` - RFC 4122 URN representation of the UUID
Copy link
Member

@tomchristie tomchristie May 8, 2015

Choose a reason for hiding this comment

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

Could we have examples here?

@tomchristie
Copy link
Member

tomchristie commented May 8, 2015

Okay one last comment regarding the docs. Otherwise good after that! :)

@jpadilla
Copy link
Member

jpadilla commented Jun 2, 2015

Closing this in favor of #3000.

@jpadilla jpadilla closed this Jun 2, 2015
@xordoquy xordoquy changed the title Add 'format' argument to UUIDField Add format argument to UUIDField Jun 3, 2015
@xordoquy
Copy link
Collaborator

xordoquy commented Jun 3, 2015

@ovangle thanks for the PR.

@ovangle
Copy link
Contributor Author

ovangle commented Jun 3, 2015

That's OK. I seem to have missed a couple of emails telling me to follow up on it. Sorry about that.

@xordoquy
Copy link
Collaborator

xordoquy commented Jun 3, 2015

@ovangle no problem at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants