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

Custom primary key serialization. #2789

Merged
merged 1 commit into from
Jun 15, 2015

Conversation

ovangle
Copy link
Contributor

@ovangle ovangle commented Apr 2, 2015

Support custom serialization options for PrimaryKeyRelatedFields.

@ovangle ovangle force-pushed the primary_key_serialization branch 3 times, most recently from 6e74d35 to e8bca56 Compare April 2, 2015 05:08
@xordoquy
Copy link
Collaborator

xordoquy commented Jun 9, 2015

I'm a bit confused about this PR against #2788

@ovangle
Copy link
Contributor Author

ovangle commented Jun 11, 2015

This PR has little to do with #2788 #3000.

Currently, the code in question assumes that the primary key's value is a primitive and passes it on to the json/xml/etc serializer to serialize. In the case of UUID's, this just calls str on the result, writing a 'verbose hex' format UUID in the serialized representation.

This may not be the desired behaviour, so I've changed the foreign key field to accept an optional subfield, which can be used to customise the output representation of the foreign key's value.

But it can be used to customise the output serialization of primary keys in general.

ps. the implementation of this should have been independent to the implementation of #2788, but the unit tests rely on being able to serialise a UUID to a format other than the verbose hex format.

Adds a 'pk_field' parameter which can be used to proxy serialization and
deserialization of arbitrary primary key values.
@ovangle ovangle force-pushed the primary_key_serialization branch from e8bca56 to a1e0bae Compare June 14, 2015 18:55
@ovangle
Copy link
Contributor Author

ovangle commented Jun 14, 2015

Rebased to use implementation from #3000.

@xordoquy xordoquy added this to the 3.1.4 Release milestone Jun 15, 2015
@xordoquy
Copy link
Collaborator

This looks good to me. Thanks for the work.
I wonder how helpful this will be for NoSQL databases.

xordoquy added a commit that referenced this pull request Jun 15, 2015
@xordoquy xordoquy merged commit 49404f6 into encode:master Jun 15, 2015
@xordoquy xordoquy changed the title Primary key serialization Custom primary key serialization. Jun 15, 2015
@tomchristie tomchristie modified the milestones: 3.1.4 Release, 3.2.0 Release Jul 30, 2015
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.

4 participants