On Jun 16, 2010, at 4:58 PM, Tom Lane wrote:
>> hstore => text[] is new in 9.0.
>
> Wup, sorry, I read this as being the other operator. Nevermind ...
>
> (FWIW, I share your dislike of & for this operator. I just haven't
> got a better idea.)
There aren't any very good choices. Possible correlates:
text[] key_slice := my_hstore -> ARRAY['foo', 'bar'];
bool has_keys := my_hstore ?& ARRAY['foo', 'bar'];
text[] keyvals := %% my_hstore;
text[] keyvals := %# my_hstore;
Frankly, %% and %# are closest, in a sense. But instead of an array, we want to get back an hstore. -> and ?& are
correlatesin that their RHSs are arrays.
Possible operators to get a slice of the hstore:
hstore slice := my_hstore +> ARRAY['foo', 'bar'];
hstore slice := my_hstore #> ARRAY['foo', 'bar'];
hstore slice := my_hstore &> ARRAY['foo', 'bar'];
hstore slice := my_hstore !> ARRAY['foo', 'bar'];
hstore slice := my_hstore *> ARRAY['foo', 'bar'];
hstore slice := my_hstore %> ARRAY['foo', 'bar'];
hstore slice := my_hstore @ ARRAY['foo', 'bar'];
hstore slice := my_hstore % ARRAY['foo', 'bar'];
hstore slice := my_hstore # ARRAY['foo', 'bar'];
hstore slice := my_hstore & ARRAY['foo', 'bar'];
hstore slice := my_hstore @# ARRAY['foo', 'bar'];
Maybe %> is good, in that it combines %% and ->, in a sense. Or #>, which kind of goes along with #=, which also
returnsan hstore.
Anyway, the more I look at it the less I care, as long as *something* works.
Best,
David