On 1/14/11 15:04 , Chris Rossi wrote:
On Fri, Jan 14, 2011 at 5:20 AM, Wichert Akkerman <wich...@wiggy.net
<mailto:wich...@wiggy.net>> wrote:
This may already be different in the trunk of repoze.catalog, but I
just stumbled over this: when you do a catalog search and ask it to
order by an empty index you get an empty result set. I was expecting
the result to be an unordered result for that situation. Is this
expected behaviour?
Hi Wichert,
I haven't observed this behavior, but it seems like an undefined case,
to me. I'm not sure what I would expect it to do in such a situation.
Supposing you have a set of documents you want sorted by an index and
the index contains only a subset of those documents? It seems to me the
case is undefined--I would have a tendency to raise an exception,
personally.
I was expecting a missing index value to be treated as None (or NULL in
SQL terms) and the related items to appear either first or last. Raising
an exception is undesirable: there are valid situations where an object
might have a None value for an indexed attribute and that should not
lead to exceptions when doing catalog queries.
I think in the interest of a well defined determinism I would suggest
that if you are using an index to sort, you should make sure that the
discriminator for that index be able to return some value for any
document. This way even if logically, to you, the document doesn't
really have a value for that index, you can at least be deterministic
about how it will be sorted.
The object did have a value, but it was None which the indexed
apparently ignores. The fact that it was always None was a bug in my
code that has been fixed now - it should be either None or a date (it
was a publication-date field).
Wichert.
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev