kulpa / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

CredentialsField and FlowField attempt to encode None values (Django ORM) #128

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an object with CredentialsField or FlowField as attribute
2. Assign None to this attribute
3. Save the object

What is the expected output? What do you see instead?
Expected output: Nothing should be written to that field in the DB.
Actual output: Base64 encoded representation of the string 'None' is encoded

What version of the product are you using? On what operating system?
python-client-1.0beta8 -> django_orm

Please provide any additional information below.
Suggested fix for both Field Types: 

def get_db_prep_value(self, value, connections, prepared=False):
    if value is None:  
        return None
    return base64.b64encode(pickle.dumps(value))

Also of note, it appears with version 1.2 of django, get_db_prep_value was 
refactored and get_prep_value is the appropriate place for this code.

Original issue reported on code.google.com by sas...@gmail.com on 20 Apr 2012 at 9:11

GoogleCodeExporter commented 9 years ago
CL out for review: http://codereview.appspot.com/6298084/

Original comment by jcgregorio@google.com on 14 Jun 2012 at 7:55

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 1fa6cdd3cf8f.

Original comment by jcgregorio@google.com on 14 Jun 2012 at 8:12