Wednesday, December 16, 2009

Tokyo Cabinet (rufus-tokyo) - TableQuery :stroreq and :numoreq

Quick note about what I found.

The documentation for Rufus::Tokyo::TableQuery says "string/number which is equal to at least one token" for :stroreq and :numoreq, respectively. But this collection of tokens cannot be an array. It must be a string with tokens separated by comma.

How did I find that array doesn't work?

First, it didn't return the expected result.

Then I looked at the code for the add method by clicking on "View source" and found that to_s is called immediately on the passed val (in this case, a collection of tokens). So if array is passed, to_s is called on it, which only returns a string concatenating all the array elements. So how the code following it can distinguish the tokens for the string, e.g. "123"? - (1 and 23) or (1 and 2 and 3), etc?

So I simply tried passing a string with tokens separated by comma, e.g. "1,2,3". Then it worked.


Anonymous said...

Salut, si tu as des remarques quant à rufus-tokyo, elles sont les bienvenues.

A bientôt, et une bonne et heureuse année 2010 !


Tadatoshi said...

Bonjour, John.

Merci beaucoup de votre remarque.