You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Matt Massie <ma...@cloudera.com> on 2009/10/29 22:56:47 UTC
python _validateunion issue?
In genericio.py, the _validateunion function looks like:
def _validateunion(schm, object):
for elemtype in schm.getelementtypes():
if validate(elemtype, object):
return True
return False
which I think only validates the first schema in a union. Shouldn't it
be...
def _validateunion(schm, object):
for elemtype in schm.getelementtypes():
if not validate(elemtype, object):
return False
return True
instead?
-Matt
Re: python _validateunion issue?
Posted by Matt Massie <ma...@cloudera.com>.
I misunderstood what validate() does. Sorry for the noise on the list.
-Matt
On Thu, Oct 29, 2009 at 10:06 PM, Sharad Agarwal <sh...@yahoo-inc.com>wrote:
> Matt Massie wrote:
>
>> In genericio.py, the _validateunion function looks like:
>>
>> def _validateunion(schm, object):
>> for elemtype in schm.getelementtypes():
>> if validate(elemtype, object):
>> return True
>> return False
>>
>> which I think only validates the first schema in a union. Shouldn't it
>> be...
>>
>>
> No. It would validate all the schemas until one is found to be matching.
>
> def _validateunion(schm, object):
>> for elemtype in schm.getelementtypes():
>> if not validate(elemtype, object):
>> return False
>> return True
>>
>> instead?
>>
>>
> If none of the schema matches, even then this would return true. no ?
>
>> -Matt
>>
>>
>>
>
>
Re: python _validateunion issue?
Posted by Sharad Agarwal <sh...@yahoo-inc.com>.
Matt Massie wrote:
> In genericio.py, the _validateunion function looks like:
>
> def _validateunion(schm, object):
> for elemtype in schm.getelementtypes():
> if validate(elemtype, object):
> return True
> return False
>
> which I think only validates the first schema in a union. Shouldn't it
> be...
>
No. It would validate all the schemas until one is found to be matching.
> def _validateunion(schm, object):
> for elemtype in schm.getelementtypes():
> if not validate(elemtype, object):
> return False
> return True
>
> instead?
>
If none of the schema matches, even then this would return true. no ?
> -Matt
>
>