Closed GoogleCodeExporter closed 9 years ago
Do not include parameters you want excluded. Supplying a parameter with a value
of None as a value has a very different meaning than not supplying the
parameter at all.
Original comment by jcgregorio@google.com
on 12 Jun 2012 at 1:10
The concern more generally is that there is no distinction between the string
"None" and the null value None.
Adding this:
req = service.translations().list(source=None, target='fr', q=['car'])
print req.uri
req = service.translations().list(source='None', target='fr', q=['car'])
print req.uri
to the translations example yields the identical strings:
https://www.googleapis.com/language/translate/v2?q=car&source=None&alt=json&target=fr&key=AIzaSyBGbYmf-u_tY_gnQCzIEicOnxVL03vf9Ow
https://www.googleapis.com/language/translate/v2?q=car&source=None&alt=json&target=fr&key=AIzaSyBGbYmf-u_tY_gnQCzIEicOnxVL03vf9Ow
I haven't tested a patch() operation, but I suspect this indistinguishability
will be particularly problematic there.
Original comment by yova...@google.com
on 12 Jun 2012 at 2:13
The library knows that the 'source' parameter in this case is supposed to be a
string and casts what you pass in as a string, thus you get 'None'. If it
happened to be an int it would raise an exception, since you can't cast a None
to int, so I could see adding code to raise an exception in the case of string
parameters to keep the behavior consistent.
Patch only applies to bodies of the request, and during a patch JSON
serialization will convert a None to null.
Original comment by jcgregorio@google.com
on 12 Jun 2012 at 2:22
Thanks for clarifying this.
An exception might be useful, but might also set a precedent for other special
cases.
Original comment by yova...@google.com
on 12 Jun 2012 at 2:38
Re-opening to track adding the exception in the case of passing in None for a
string parameter.
Original comment by jcgregorio@google.com
on 12 Jun 2012 at 2:59
CL out for review: http://codereview.appspot.com/6306085/
Original comment by jcgregorio@google.com
on 14 Jun 2012 at 7:57
Fixed in
http://code.google.com/p/google-api-python-client/source/detail?r=e283dfe361a674
2f621f4699a81c23d78a3bcc12
Original comment by jcgregorio@google.com
on 14 Jun 2012 at 8:19
Based on feedback changing the behavior so that None means to ignore the
parameter.
CL out for review: http://codereview.appspot.com/6295108/
Original comment by jcgregorio@google.com
on 20 Jun 2012 at 4:00
This issue was closed by revision 97e37f2a20c1.
Original comment by jcgregorio@google.com
on 20 Jun 2012 at 4:22
Original issue reported on code.google.com by
yova...@google.com
on 11 Jun 2012 at 10:21